From d47e0bac601c7f6e8af58074b75edac3d060d66f Mon Sep 17 00:00:00 2001 From: Ferenc Hammerl <31069338+fhammerl@users.noreply.github.com> Date: Mon, 6 Mar 2023 11:02:29 +0100 Subject: [PATCH] Support '*' wildcard (#1355) --- packages/http-client/__tests__/proxy.test.ts | 9 +++++++-- packages/http-client/src/proxy.ts | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/http-client/__tests__/proxy.test.ts b/packages/http-client/__tests__/proxy.test.ts index ccbceec2..60077a58 100644 --- a/packages/http-client/__tests__/proxy.test.ts +++ b/packages/http-client/__tests__/proxy.test.ts @@ -176,11 +176,16 @@ describe('proxy', () => { expect(bypass).toBeTruthy() }) - // Do not match wildcard ("*") as per https://github.com/actions/runner/blob/97195bad5870e2ad0915ebfef1616083aacf5818/docs/adrs/0263-proxy-support.md it('checkBypass returns true if no_proxy is "*"', () => { process.env['no_proxy'] = '*' const bypass = pm.checkBypass(new URL('https://anything.whatsoever.com')) - expect(bypass).toBeFalsy() + expect(bypass).toBeTruthy() + }) + + it('checkBypass returns true if no_proxy contains comma separated "*"', () => { + process.env['no_proxy'] = 'domain.com,* , example.com' + const bypass = pm.checkBypass(new URL('https://anything.whatsoever.com')) + expect(bypass).toBeTruthy() }) it('HttpClient does basic http get request through proxy', async () => { diff --git a/packages/http-client/src/proxy.ts b/packages/http-client/src/proxy.ts index e4e43a54..3c84c586 100644 --- a/packages/http-client/src/proxy.ts +++ b/packages/http-client/src/proxy.ts @@ -52,6 +52,7 @@ export function checkBypass(reqUrl: URL): boolean { .map(x => x.trim().toUpperCase()) .filter(x => x)) { if ( + upperNoProxyItem === '*' || upperReqHosts.some( x => x === upperNoProxyItem ||