From d60f9c2549c7dfb0fbd6c9c8984c215f5dd75e76 Mon Sep 17 00:00:00 2001 From: JohannLai Date: Fri, 17 Jul 2020 00:08:29 +0800 Subject: fix(cli/js/web): IPv6 hostname should be compressed (#6772) --- cli/js/web/url.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cli/js') diff --git a/cli/js/web/url.ts b/cli/js/web/url.ts index f466f9583..fabef3329 100644 --- a/cli/js/web/url.ts +++ b/cli/js/web/url.ts @@ -565,7 +565,8 @@ function encodeHostname(s: string, isSpecial = true): string { if (!s.match(/^\[[0-9A-Fa-f.:]{2,}\]$/)) { throw new TypeError("Invalid hostname."); } - return s.toLowerCase(); + // IPv6 address compress + return s.toLowerCase().replace(/\b:?(?:0+:?){2,}/, "::"); } let result = s; -- cgit v1.2.3