mirror of
https://github.com/crazy-max/ghaction-upx.git
synced 2024-11-25 03:36:08 -07:00
40 lines
1.1 KiB
JavaScript
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;
|