1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 21:07:34 +00:00
serenity/Tests/LibWeb/Text/input/URL/url.html
Shannon Booth faf9d08371 AK: Fix IPv6 serialization on multiple '0' parts ending in a '0' part
This could happen if a sequence of '0' parts was followed by a longer
sequence of '0' parts at the end of the host. The first sequence was
being used for the compress, and not the second.

For example, [1:1:0:0:1:0:0:0] was being serialized as: [1:1::1:0:0:0]
instead of [1:1:0:0:1::].

Fix this by checking at the end of the loop if we are in the middle of a
sequence of '0' parts that is longer than the current longest.
2023-08-06 10:53:32 +02:00

26 lines
840 B
HTML

<script src="../include.js"></script>
<script>
test(() => {
function printURL(input) {
println(input);
const url = new URL(input);
println(`protocol => '${url.protocol}'`);
println(`username => '${url.username}'`);
println(`password => '${url.password}'`);
println(`host => '${url.host}'`);
println(`hostname => '${url.hostname}'`);
println(`port => '${url.port}'`);
println(`pathname => '${url.pathname}'`);
println(`search => '${url.search}'`);
}
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]',
'http://[1:1:0:0:1:0:0:0]/',
]) {
printURL(url);
}
});
</script>