From 0e1634aa9a5f9abc2789292598650ea4de798054 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 20:00:11 +0200 Subject: [PATCH] test: expand shouldBypassProxy coverage for wildcard, IPv6, and edge cases (#10723) * Initial plan * test: add shouldBypassProxy coverage for wildcard, ipv6 port and edge cases Agent-Logs-Url: https://github.com/axios/axios/sessions/2986cafc-965b-4aea-b076-60f954e7eba5 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- tests/unit/helpers/shouldBypassProxy.test.js | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/unit/helpers/shouldBypassProxy.test.js b/tests/unit/helpers/shouldBypassProxy.test.js index 6e63143a..4a3deacb 100644 --- a/tests/unit/helpers/shouldBypassProxy.test.js +++ b/tests/unit/helpers/shouldBypassProxy.test.js @@ -73,4 +73,31 @@ describe('helpers::shouldBypassProxy', () => { expect(shouldBypassProxy('http://localhost:8080/')).toBe(true); expect(shouldBypassProxy('http://localhost:8081/')).toBe(false); }); + + it('should bypass proxy for any host when no_proxy is *', () => { + setNoProxy('*'); + + expect(shouldBypassProxy('http://example.com/')).toBe(true); + expect(shouldBypassProxy('http://localhost:1234/')).toBe(true); + expect(shouldBypassProxy('http://[::1]:8080/')).toBe(true); + }); + + it('should support bracketed ipv6 with explicit port in no_proxy', () => { + setNoProxy('[::1]:8080'); + + expect(shouldBypassProxy('http://[::1]:8080/')).toBe(true); + expect(shouldBypassProxy('http://[::1]:8081/')).toBe(false); + }); + + it('should not bypass when no_proxy is empty', () => { + setNoProxy(''); + + expect(shouldBypassProxy('http://localhost:8080/')).toBe(false); + }); + + it('should not bypass for malformed URLs', () => { + setNoProxy('localhost,127.0.0.1,::1'); + + expect(shouldBypassProxy('not a url')).toBe(false); + }); });