From af3cced9e00e77709123565d38205564ea4b6512 Mon Sep 17 00:00:00 2001 From: tillganster <49649012+tillganster@users.noreply.github.com> Date: Wed, 17 Aug 2022 05:25:36 +0200 Subject: [PATCH] feat: support no_proxy environment variable (#1205) Co-authored-by: TGANSTE --- src/octokit-client.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/octokit-client.ts b/src/octokit-client.ts index adf32f00c..afb1c3ec2 100644 --- a/src/octokit-client.ts +++ b/src/octokit-client.ts @@ -11,13 +11,23 @@ export const Octokit = Core.plugin( autoProxyAgent ) -// Octokit plugin to support the https_proxy environment variable +// Octokit plugin to support the https_proxy and no_proxy environment variable function autoProxyAgent(octokit: Core) { const proxy = process.env.https_proxy || process.env.HTTPS_PROXY + + const noProxy = process.env.no_proxy || process.env.NO_PROXY + let noProxyArray: string[] = [] + if (noProxy) { + noProxyArray = noProxy.split(',') + } + if (!proxy) return const agent = new HttpsProxyAgent(proxy) octokit.hook.before('request', options => { + if (noProxyArray.includes(options.request.hostname)) { + return + } options.request.agent = agent }) }