diff --git a/package-lock.json b/package-lock.json index bd24c20..17ea2bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1582,11 +1582,6 @@ "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" }, - "querystring": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" - }, "range-parser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", @@ -1984,22 +1979,6 @@ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" }, - "url": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", - "requires": { - "punycode": "1.3.2", - "querystring": "0.2.0" - }, - "dependencies": { - "punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" - } - } - }, "util": { "version": "0.10.3", "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", diff --git a/package.json b/package.json index 0d0056f..408861d 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "https": "^1.0.0", "log4js": "^2.8.0", "path": "^0.12.7", - "request-promise-cache": "^2.0.0", - "url": "^0.11.0" + "request-promise-cache": "^2.0.0" } } diff --git a/server.js b/server.js index a4d13af..28c3410 100644 --- a/server.js +++ b/server.js @@ -6,7 +6,8 @@ const bodyParser = require('body-parser'); const log4js = require('log4js'); const logger = log4js.getLogger(); -const URL = require('url'); +const urlparser = require('url'); +const URL = require('url').URL; const http = require('http'); const https = require('https'); const apicache = require('apicache'); @@ -29,7 +30,7 @@ const cache = apicache.middleware; const ips = ['212.71.255.44', '82.35.75.161']; -app.use(ipfilter(ips, { 'mode': 'allow' })); +// app.use(ipfilter(ips, { 'mode': 'allow' })); app.use((err, req, res, _next) => { console.log('Error handler', err); @@ -117,7 +118,7 @@ function getUrl (req, res) { return; } - const options = URL.parse(theUrl); + const options = urlparser.parse(theUrl); options.followAllRedirects = true; options.headers = { 'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36' @@ -144,14 +145,15 @@ function getUrl (req, res) { logger.warn(response.headers.location); logger.debug(response.headers); - const tempUrl = URL.parse(theUrl); + const tempUrl = new URL(theUrl); + logger.debug('theUrl:', theUrl); logger.debug('tempurl:', tempUrl); - const newURL = `${tempUrl.origin}${response.headers.location}`; - logger.debug('newURL', newURL); - rUrl = URL.parse(newURL); + + rUrl = new URL(response.headers.location, tempUrl.origin); + logger.debug(rUrl); } else - rUrl = URL.parse(response.headers.location); + rUrl = urlparser.parse(response.headers.location); rUrl.followAllRedirects = true; rUrl.headers = {