diff --git a/lib/util.js b/lib/util.js index 3147ef848..90db5d079 100644 --- a/lib/util.js +++ b/lib/util.js @@ -862,9 +862,10 @@ exports.validateEmptyString = function (value) { }; exports.getProxyFromEnv = function (isHttps = true) { - const getDefaultPortIfNotSet = (proxyFromEnv, isHttps) => { + const getDefaultPortIfNotSet = (proxyFromEnv) => { + const isProxyProtocolHttps = proxyFromEnv.protocol === 'https:'; if (!proxyFromEnv.port) { - return isHttps ? 443 : 80; + return isProxyProtocolHttps ? 443 : 80; } else { return proxyFromEnv.port; } @@ -879,10 +880,9 @@ exports.getProxyFromEnv = function (isHttps = true) { if (proxyFromEnv.indexOf('://') === -1) { Logger.getInstance().info('Util.getProxyEnv: the protocol was missing from the environment proxy. Use the HTTP protocol.'); proxyFromEnv = 'http' + '://' + proxyFromEnv; - isHttps = false; } proxyFromEnv = new URL(proxyFromEnv); - const port = getDefaultPortIfNotSet(proxyFromEnv, isHttps); + const port = getDefaultPortIfNotSet(proxyFromEnv); const proxy = { host: this.validateEmptyString(proxyFromEnv.hostname), port: Number(port),