diff --git a/packages/core/src/utils/proxyUtils.test.ts b/packages/core/src/utils/proxyUtils.test.ts index 750e45a69..7f7a54373 100644 --- a/packages/core/src/utils/proxyUtils.test.ts +++ b/packages/core/src/utils/proxyUtils.test.ts @@ -77,4 +77,28 @@ describe('normalizeProxyUrl', () => { it('should handle IPv6 addresses with http:// prefix', () => { expect(normalizeProxyUrl('http://[::1]:8080')).toBe('http://[::1]:8080'); }); + + it('should not modify URL that already has socks:// prefix', () => { + expect(normalizeProxyUrl('socks://proxy.example.com:1080')).toBe( + 'socks://proxy.example.com:1080', + ); + }); + + it('should not modify URL that already has socks4:// prefix', () => { + expect(normalizeProxyUrl('socks4://proxy.example.com:1080')).toBe( + 'socks4://proxy.example.com:1080', + ); + }); + + it('should not modify URL that already has socks5:// prefix', () => { + expect(normalizeProxyUrl('socks5://proxy.example.com:1080')).toBe( + 'socks5://proxy.example.com:1080', + ); + }); + + it('should handle SOCKS:// prefix (case insensitive)', () => { + expect(normalizeProxyUrl('SOCKS5://proxy.example.com:1080')).toBe( + 'SOCKS5://proxy.example.com:1080', + ); + }); }); diff --git a/packages/core/src/utils/proxyUtils.ts b/packages/core/src/utils/proxyUtils.ts index eb776ec71..30e42654d 100644 --- a/packages/core/src/utils/proxyUtils.ts +++ b/packages/core/src/utils/proxyUtils.ts @@ -27,7 +27,8 @@ export function normalizeProxyUrl( } // Check if the URL already has a protocol prefix - if (/^https?:\/\//i.test(trimmed)) { + // Support http, https, socks, socks4, socks5 protocols + if (/^(https?|socks[45]?):\/\//i.test(trimmed)) { return trimmed; }