github.com/jfrog/frogbot@v1.1.1-0.20231221090046-821a26f50338/action/node_modules/@actions/http-client/lib/proxy.js (about) 1 "use strict"; 2 Object.defineProperty(exports, "__esModule", { value: true }); 3 exports.checkBypass = exports.getProxyUrl = void 0; 4 function getProxyUrl(reqUrl) { 5 const usingSsl = reqUrl.protocol === 'https:'; 6 if (checkBypass(reqUrl)) { 7 return undefined; 8 } 9 const proxyVar = (() => { 10 if (usingSsl) { 11 return process.env['https_proxy'] || process.env['HTTPS_PROXY']; 12 } 13 else { 14 return process.env['http_proxy'] || process.env['HTTP_PROXY']; 15 } 16 })(); 17 if (proxyVar) { 18 return new URL(proxyVar); 19 } 20 else { 21 return undefined; 22 } 23 } 24 exports.getProxyUrl = getProxyUrl; 25 function checkBypass(reqUrl) { 26 if (!reqUrl.hostname) { 27 return false; 28 } 29 const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; 30 if (!noProxy) { 31 return false; 32 } 33 // Determine the request port 34 let reqPort; 35 if (reqUrl.port) { 36 reqPort = Number(reqUrl.port); 37 } 38 else if (reqUrl.protocol === 'http:') { 39 reqPort = 80; 40 } 41 else if (reqUrl.protocol === 'https:') { 42 reqPort = 443; 43 } 44 // Format the request hostname and hostname with port 45 const upperReqHosts = [reqUrl.hostname.toUpperCase()]; 46 if (typeof reqPort === 'number') { 47 upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); 48 } 49 // Compare request host against noproxy 50 for (const upperNoProxyItem of noProxy 51 .split(',') 52 .map(x => x.trim().toUpperCase()) 53 .filter(x => x)) { 54 if (upperReqHosts.some(x => x === upperNoProxyItem)) { 55 return true; 56 } 57 } 58 return false; 59 } 60 exports.checkBypass = checkBypass; 61 //# sourceMappingURL=proxy.js.map