Replace deprecated URL parser

Fix up various linter errors
This commit is contained in:
Lovell Fuller
2019-09-22 22:46:28 +01:00
parent 14af0bda61
commit 9c7f6fcb2b
9 changed files with 402 additions and 397 deletions

View File

@@ -20,15 +20,18 @@ function env (key) {
module.exports = function () {
try {
const proxy = url.parse(proxies.map(env).find(is.string));
const proxy = new url.URL(proxies.map(env).find(is.string));
const tunnel = proxy.protocol === 'https:'
? tunnelAgent.httpsOverHttps
: tunnelAgent.httpsOverHttp;
const proxyAuth = proxy.username && proxy.password
? `${proxy.username}:${proxy.password}`
: null;
return tunnel({
proxy: {
port: Number(proxy.port),
host: proxy.hostname,
proxyAuth: proxy.auth
proxyAuth
}
});
} catch (err) {

View File

@@ -517,7 +517,7 @@ const formats = new Map([
function toFormat (format, options) {
const actualFormat = formats.get(is.object(format) && is.string(format.id) ? format.id : format);
if (!actualFormat) {
throw is.invalidParameterError('format', `one of: ${[...formats.keys()].join(`, `)}`, format);
throw is.invalidParameterError('format', `one of: ${[...formats.keys()].join(', ')}`, format);
}
return this[actualFormat](options);
}