1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:17:35 +00:00

AK: Fix url host parsing check for 'ends in a number'

I misunderstood the spec step for checking whether the host 'ends with a
number'. We can't simply check for it if ends with a number, this check
is actually an algorithm which is required to avoid detecting hosts that
end with a number from an IPv4 host.

Implement this missing step, and add a test to cover this.
This commit is contained in:
Shannon Booth 2023-07-25 19:43:00 +12:00 committed by Tim Flynn
parent 715b6f868f
commit 177b04dcfc
2 changed files with 42 additions and 1 deletions

View file

@ -38,6 +38,16 @@ TEST_CASE(basic)
EXPECT(url.query().is_null());
EXPECT(url.fragment().is_null());
}
{
URL url("https://www.serenityos.org1/index.html"sv);
EXPECT_EQ(url.is_valid(), true);
EXPECT_EQ(url.scheme(), "https");
EXPECT_EQ(url.host(), "www.serenityos.org1");
EXPECT_EQ(url.port_or_default(), 443);
EXPECT_EQ(url.serialize_path(), "/index.html");
EXPECT(url.query().is_null());
EXPECT(url.fragment().is_null());
}
{
URL url("https://localhost:1234/~anon/test/page.html"sv);
EXPECT_EQ(url.is_valid(), true);