fix comment

This commit is contained in:
DennisYu07 2026-03-30 14:54:17 +08:00
parent bba3ab93b1
commit 588ef60411
2 changed files with 26 additions and 1 deletions

View file

@ -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',
);
});
});

View file

@ -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;
}