1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 15:27:34 +00:00

AK: Fix bad parsing of some file:/// URLs with base URL

We were dropping the base URL path components in the resulting URL due
to mistakenly determining the input URL to start with a Windows drive
letter. Fix this, add a spec link, and a test.
This commit is contained in:
Andreas Kling 2022-09-20 15:38:53 +02:00
parent ac76df3d47
commit 287a9b552a
2 changed files with 16 additions and 1 deletions

View file

@ -392,3 +392,17 @@ TEST_CASE(unicode)
EXPECT(url.query().is_null());
EXPECT(url.fragment().is_null());
}
TEST_CASE(complete_file_url_with_base)
{
URL url { "file:///home/index.html" };
EXPECT(url.is_valid());
EXPECT_EQ(url.path(), "/home/index.html");
EXPECT_EQ(url.paths().size(), 2u);
EXPECT_EQ(url.paths()[0], "home");
EXPECT_EQ(url.paths()[1], "index.html");
auto sub_url = url.complete_url("js/app.js");
EXPECT(sub_url.is_valid());
EXPECT_EQ(sub_url.path(), "/home/js/app.js");
}