From 5e5493e334f10106e03f3c4c413b1f34c612a9df Mon Sep 17 00:00:00 2001 From: Valtteri Koskivuori Date: Sun, 18 Jun 2023 02:43:11 +0300 Subject: [PATCH] AK: Add URLParser relative file URL test I was debugging a different issue in Ladybird, and noticed that completing relative file URLs with URL::complete_url didn't seem to work right. This test case covers both the working https case, as well as the file URL case fixed by the previous commit. --- Tests/AK/TestURL.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tests/AK/TestURL.cpp b/Tests/AK/TestURL.cpp index 52024c64a0..97c5541b0f 100644 --- a/Tests/AK/TestURL.cpp +++ b/Tests/AK/TestURL.cpp @@ -184,6 +184,12 @@ TEST_CASE(file_url_serialization) EXPECT_EQ(URL("file:///my/file#fragment"sv).serialize(), "file:///my/file#fragment"); } +TEST_CASE(file_url_relative) +{ + EXPECT_EQ(URL("https://vkoskiv.com/index.html"sv).complete_url("/static/foo.js"sv).serialize(), "https://vkoskiv.com/static/foo.js"); + EXPECT_EQ(URL("file:///home/vkoskiv/test/index.html"sv).complete_url("/static/foo.js"sv).serialize(), "file:///home/vkoskiv/test/static/foo.js"); +} + TEST_CASE(about_url) { URL url("about:blank"sv);