Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support '*' wildcard in no_proxy #1355

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/http-client/__tests__/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
1 change: 1 addition & 0 deletions packages/http-client/src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down