diff options
author | Josh Byrnes <204185+realJoshByrnes@users.noreply.github.com> | 2020-06-11 04:05:10 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-10 14:05:10 -0400 |
commit | 408edbb065cb0a7b375d83df5c7f61f62b4d47e6 (patch) | |
tree | eb42e4c1da5943298017edf38dda057d38f5defc /cli/tests/unit/url_test.ts | |
parent | 1120dfe3f2d5732eb2eda0996726efd33554e42c (diff) |
fix(URL): IPv6 hostname support (#5766)
Diffstat (limited to 'cli/tests/unit/url_test.ts')
-rw-r--r-- | cli/tests/unit/url_test.ts | 22 |
1 files changed, 22 insertions, 0 deletions
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 { |