From 408edbb065cb0a7b375d83df5c7f61f62b4d47e6 Mon Sep 17 00:00:00 2001 From: Josh Byrnes <204185+realJoshByrnes@users.noreply.github.com> Date: Thu, 11 Jun 2020 04:05:10 +1000 Subject: fix(URL): IPv6 hostname support (#5766) --- cli/tests/unit/url_test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/unit/url_test.ts b/cli/tests/unit/url_test.ts index 68fcbd95e..b4c31ea6d 100644 --- a/cli/tests/unit/url_test.ts +++ b/cli/tests/unit/url_test.ts @@ -29,6 +29,28 @@ unitTest(function urlParsing(): void { JSON.stringify({ key: url }), `{"key":"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat"}` ); + + // IPv6 type hostname. + const urlv6 = new URL( + "https://foo:bar@[::1]:8000/qux/quux?foo=bar&baz=12#qat" + ); + assertEquals(urlv6.origin, "https://[::1]:8000"); + assertEquals(urlv6.password, "bar"); + assertEquals(urlv6.pathname, "/qux/quux"); + assertEquals(urlv6.port, "8000"); + assertEquals(urlv6.protocol, "https:"); + assertEquals(urlv6.search, "?foo=bar&baz=12"); + assertEquals(urlv6.searchParams.getAll("foo"), ["bar"]); + assertEquals(urlv6.searchParams.getAll("baz"), ["12"]); + assertEquals(urlv6.username, "foo"); + assertEquals( + String(urlv6), + "https://foo:bar@[::1]:8000/qux/quux?foo=bar&baz=12#qat" + ); + assertEquals( + JSON.stringify({ key: urlv6 }), + `{"key":"https://foo:bar@[::1]:8000/qux/quux?foo=bar&baz=12#qat"}` + ); }); unitTest(function urlModifications(): void { -- cgit v1.2.3