ghaction-upx/node_modules/@actions/http-client/proxy.js
2020-01-17 09:39:25 +01:00

40 lines
1.1 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const url = require("url");
function getProxyUrl(reqUrl) {
let usingSsl = reqUrl.protocol === 'https:';
let noProxy = process.env["no_proxy"] ||
process.env["NO_PROXY"];
let bypass;
if (noProxy && typeof noProxy === 'string') {
let bypassList = noProxy.split(',');
for (let i = 0; i < bypassList.length; i++) {
let item = bypassList[i];
if (item &&
typeof item === "string" &&
reqUrl.host.toLocaleLowerCase() == item.trim().toLocaleLowerCase()) {
bypass = true;
break;
}
}
}
let proxyUrl;
if (bypass) {
return proxyUrl;
}
let proxyVar;
if (usingSsl) {
proxyVar = process.env["https_proxy"] ||
process.env["HTTPS_PROXY"];
}
else {
proxyVar = process.env["http_proxy"] ||
process.env["HTTP_PROXY"];
}
if (proxyVar) {
proxyUrl = url.parse(proxyVar);
}
return proxyUrl;
}
exports.getProxyUrl = getProxyUrl;