aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node_modules/@actions/http-client/lib/proxy.js
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-12-11 15:42:38 +0100
committerEgor Tensin <Egor.Tensin@gmail.com>2022-12-11 15:42:38 +0100
commit9857fae4d1136ef2ebfeffaaaf6ba22e1015401a (patch)
tree8d88c98d2100e29b668df3845088565cde9d80c6 /node_modules/@actions/http-client/lib/proxy.js
parentbump Node version (diff)
downloadcleanup-path-9857fae4d1136ef2ebfeffaaaf6ba22e1015401a.tar.gz
cleanup-path-9857fae4d1136ef2ebfeffaaaf6ba22e1015401a.zip
upgrade actions/core
Diffstat (limited to 'node_modules/@actions/http-client/lib/proxy.js')
-rw-r--r--node_modules/@actions/http-client/lib/proxy.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/node_modules/@actions/http-client/lib/proxy.js b/node_modules/@actions/http-client/lib/proxy.js
new file mode 100644
index 0000000..528ffe4
--- /dev/null
+++ b/node_modules/@actions/http-client/lib/proxy.js
@@ -0,0 +1,61 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.checkBypass = exports.getProxyUrl = void 0;
+function getProxyUrl(reqUrl) {
+ const usingSsl = reqUrl.protocol === 'https:';
+ if (checkBypass(reqUrl)) {
+ return undefined;
+ }
+ const proxyVar = (() => {
+ if (usingSsl) {
+ return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
+ }
+ else {
+ return process.env['http_proxy'] || process.env['HTTP_PROXY'];
+ }
+ })();
+ if (proxyVar) {
+ return new URL(proxyVar);
+ }
+ else {
+ return undefined;
+ }
+}
+exports.getProxyUrl = getProxyUrl;
+function checkBypass(reqUrl) {
+ if (!reqUrl.hostname) {
+ return false;
+ }
+ const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
+ if (!noProxy) {
+ return false;
+ }
+ // Determine the request port
+ let reqPort;
+ if (reqUrl.port) {
+ reqPort = Number(reqUrl.port);
+ }
+ else if (reqUrl.protocol === 'http:') {
+ reqPort = 80;
+ }
+ else if (reqUrl.protocol === 'https:') {
+ reqPort = 443;
+ }
+ // Format the request hostname and hostname with port
+ const upperReqHosts = [reqUrl.hostname.toUpperCase()];
+ if (typeof reqPort === 'number') {
+ upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
+ }
+ // Compare request host against noproxy
+ for (const upperNoProxyItem of noProxy
+ .split(',')
+ .map(x => x.trim().toUpperCase())
+ .filter(x => x)) {
+ if (upperReqHosts.some(x => x === upperNoProxyItem)) {
+ return true;
+ }
+ }
+ return false;
+}
+exports.checkBypass = checkBypass;
+//# sourceMappingURL=proxy.js.map \ No newline at end of file