diff --git a/Tests/LibURL/TestURL.cpp b/Tests/LibURL/TestURL.cpp index e57ba732dd1..44a13dccc3d 100644 --- a/Tests/LibURL/TestURL.cpp +++ b/Tests/LibURL/TestURL.cpp @@ -196,7 +196,9 @@ TEST_CASE(file_url_serialization) TEST_CASE(file_url_relative) { EXPECT_EQ(URL::URL("https://vkoskiv.com/index.html"sv).complete_url("/static/foo.js"sv).serialize(), "https://vkoskiv.com/static/foo.js"); - EXPECT_EQ(URL::URL("file:///home/vkoskiv/test/index.html"sv).complete_url("/static/foo.js"sv).serialize(), "file:///home/vkoskiv/test/static/foo.js"); + EXPECT_EQ(URL::URL("file:///home/vkoskiv/test/index.html"sv).complete_url("/static/foo.js"sv).serialize(), "file:///static/foo.js"); + EXPECT_EQ(URL::URL("https://vkoskiv.com/index.html"sv).complete_url("static/foo.js"sv).serialize(), "https://vkoskiv.com/static/foo.js"); + EXPECT_EQ(URL::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) diff --git a/Tests/LibWeb/Text/expected/URL/url.txt b/Tests/LibWeb/Text/expected/URL/url.txt index 1bde4457716..6f63b783fbb 100644 --- a/Tests/LibWeb/Text/expected/URL/url.txt +++ b/Tests/LibWeb/Text/expected/URL/url.txt @@ -118,6 +118,16 @@ port => '' pathname => '/foo/bar' search => '' hash => '' +new URL('/c:/foo/bar', 'file:///c:/baz/qux') +protocol => 'file:' +username => '' +password => '' +host => '' +hostname => '' +port => '' +pathname => '/c:/foo/bar' +search => '' +hash => '' ========================================= URL.parse('ftp://serenityos.org:21', undefined) protocol => 'ftp:' @@ -239,3 +249,13 @@ port => '' pathname => '/foo/bar' search => '' hash => '' +URL.parse('/c:/foo/bar', 'file:///c:/baz/qux') +protocol => 'file:' +username => '' +password => '' +host => '' +hostname => '' +port => '' +pathname => '/c:/foo/bar' +search => '' +hash => '' diff --git a/Tests/LibWeb/Text/input/URL/url.html b/Tests/LibWeb/Text/input/URL/url.html index 644590bbb2a..9f1ec0b3c92 100644 --- a/Tests/LibWeb/Text/input/URL/url.html +++ b/Tests/LibWeb/Text/input/URL/url.html @@ -33,6 +33,7 @@ { input: 'http://user%20name:pa%40ss%3Aword@www.ladybird.org' }, { input: 'h\tt\nt\rp://h\to\ns\rt:9\t0\n0\r0/p\ta\nt\rh?q\tu\ne\rry#f\tr\na\rg' }, { input: ' \t', base: 'http://ladybird.org/foo/bar' }, + { input: '/c:/foo/bar', base: 'file:///c:/baz/qux' }, ]; for (url of urls) { diff --git a/Userland/Libraries/LibURL/Parser.cpp b/Userland/Libraries/LibURL/Parser.cpp index ad593ce5069..2c0044a6799 100644 --- a/Userland/Libraries/LibURL/Parser.cpp +++ b/Userland/Libraries/LibURL/Parser.cpp @@ -1444,10 +1444,6 @@ URL Parser::basic_parse(StringView raw_input, Optional const& base_url, Opt // 1. Set url’s host to base’s host. url->m_data->host = base_url->m_data->host; - // FIXME: The spec does not seem to mention these steps. - url->m_data->paths = base_url->m_data->paths; - url->m_data->paths.remove(url->m_data->paths.size() - 1); - // 2. If the code point substring from pointer to the end of input does not start with a Windows drive letter and base’s path[0] is a normalized Windows drive letter, then append base’s path[0] to url’s path. auto substring_from_pointer = input.substring_view(iterator - input.begin()).as_string(); if (!starts_with_windows_drive_letter(substring_from_pointer) && is_normalized_windows_drive_letter(base_url->m_data->paths[0]))