diff --git a/AK/URLParser.cpp b/AK/URLParser.cpp index d932a3a1e4c..f3397b2ed32 100644 --- a/AK/URLParser.cpp +++ b/AK/URLParser.cpp @@ -232,7 +232,6 @@ static void serialize_ipv6_address(URL::IPv6Address const& address, StringBuilde // 1. Let output be the empty string. // 2. Let compress be an index to the first IPv6 piece in the first longest sequences of address’s IPv6 pieces that are 0. - // 3. If there is no sequence of address’s IPv6 pieces that are 0 that is longer than 1, then set compress to null. Optional compress; size_t longest_sequence_length = 0; size_t current_sequence_length = 0; @@ -250,6 +249,11 @@ static void serialize_ipv6_address(URL::IPv6Address const& address, StringBuilde current_sequence_length = 0; } } + + // 3. If there is no sequence of address’s IPv6 pieces that are 0 that is longer than 1, then set compress to null. + if (longest_sequence_length <= 1) + compress = {}; + // 4. Let ignore0 be false. auto ignore0 = false; diff --git a/Tests/LibWeb/Text/expected/URL/url.txt b/Tests/LibWeb/Text/expected/URL/url.txt index ae26759dc9c..3f88ac429be 100644 --- a/Tests/LibWeb/Text/expected/URL/url.txt +++ b/Tests/LibWeb/Text/expected/URL/url.txt @@ -7,3 +7,21 @@ hostname => 'serenityos.org' port => '' pathname => '/' search => '' +http://[0:1:0:1:0:1:0:1] +protocol => 'http:' +username => '' +password => '' +host => '[0:1:0:1:0:1:0:1]' +hostname => '[0:1:0:1:0:1:0:1]' +port => '' +pathname => '/' +search => '' +http://[1:0:1:0:1:0:1:0] +protocol => 'http:' +username => '' +password => '' +host => '[1:0:1:0:1:0:1:0]' +hostname => '[1:0:1:0:1:0:1:0]' +port => '' +pathname => '/' +search => '' diff --git a/Tests/LibWeb/Text/input/URL/url.html b/Tests/LibWeb/Text/input/URL/url.html index c37a2ef030f..3626fa9b972 100644 --- a/Tests/LibWeb/Text/input/URL/url.html +++ b/Tests/LibWeb/Text/input/URL/url.html @@ -16,6 +16,8 @@ for (url of [ 'ftp://serenityos.org:21', + 'http://[0:1:0:1:0:1:0:1]', + 'http://[1:0:1:0:1:0:1:0]', ]) { printURL(url); }