diff --git a/Tests/LibWeb/Text/expected/URL/url.txt b/Tests/LibWeb/Text/expected/URL/url.txt index 6f63b783fbb..65440d2b6bf 100644 --- a/Tests/LibWeb/Text/expected/URL/url.txt +++ b/Tests/LibWeb/Text/expected/URL/url.txt @@ -128,6 +128,16 @@ port => '' pathname => '/c:/foo/bar' search => '' hash => '' +new URL('', 'file:///test?test#test') +protocol => 'file:' +username => '' +password => '' +host => '' +hostname => '' +port => '' +pathname => '/test' +search => '?test' +hash => '' ========================================= URL.parse('ftp://serenityos.org:21', undefined) protocol => 'ftp:' @@ -259,3 +269,13 @@ port => '' pathname => '/c:/foo/bar' search => '' hash => '' +URL.parse('', 'file:///test?test#test') +protocol => 'file:' +username => '' +password => '' +host => '' +hostname => '' +port => '' +pathname => '/test' +search => '?test' +hash => '' diff --git a/Tests/LibWeb/Text/input/URL/url.html b/Tests/LibWeb/Text/input/URL/url.html index 9f1ec0b3c92..288bf15713e 100644 --- a/Tests/LibWeb/Text/input/URL/url.html +++ b/Tests/LibWeb/Text/input/URL/url.html @@ -34,6 +34,7 @@ { 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' }, + { input: '', base: 'file:///test?test#test' }, ]; for (url of urls) { diff --git a/Userland/Libraries/LibURL/Parser.cpp b/Userland/Libraries/LibURL/Parser.cpp index 6d85309570d..36a67998c39 100644 --- a/Userland/Libraries/LibURL/Parser.cpp +++ b/Userland/Libraries/LibURL/Parser.cpp @@ -794,8 +794,6 @@ ErrorOr Parser::percent_encode_after_encoding(StringView input, PercentE URL Parser::basic_parse(StringView raw_input, Optional const& base_url, Optional url, Optional state_override) { dbgln_if(URL_PARSER_DEBUG, "URL::Parser::basic_parse: Parsing '{}'", raw_input); - if (raw_input.is_empty()) - return base_url.has_value() ? *base_url : URL {}; size_t start_index = 0; size_t end_index = raw_input.length();