Skip to content

Commit

Permalink
SNOW-1825719 - setting proxy port if default was skipped during parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pmotacki committed Nov 26, 2024
1 parent 90d3250 commit ba8b70d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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),
Expand Down

0 comments on commit ba8b70d

Please sign in to comment.