mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:28:11 +00:00
AK: Correctly set host when parsing URL with a base file:// host
We were completely missing this spec step here. Also leave a FIXME for the pre-existing implementation of this step, as this doesn't match the spec.
This commit is contained in:
parent
791ad12031
commit
bfdf7779ce
3 changed files with 14 additions and 0 deletions
|
@ -1377,6 +1377,9 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
|
||||||
// 1. If base is non-null and base’s scheme is "file", then:
|
// 1. If base is non-null and base’s scheme is "file", then:
|
||||||
if (base_url.has_value() && base_url->m_scheme == "file") {
|
if (base_url.has_value() && base_url->m_scheme == "file") {
|
||||||
// 1. Set url’s host to base’s host.
|
// 1. Set url’s host to base’s host.
|
||||||
|
url->m_host = base_url->m_host;
|
||||||
|
|
||||||
|
// FIXME: The spec does not seem to mention these steps.
|
||||||
url->m_paths = base_url->m_paths;
|
url->m_paths = base_url->m_paths;
|
||||||
url->m_paths.remove(url->m_paths.size() - 1);
|
url->m_paths.remove(url->m_paths.size() - 1);
|
||||||
|
|
||||||
|
|
|
@ -58,3 +58,13 @@ port => ''
|
||||||
pathname => '/cat'
|
pathname => '/cat'
|
||||||
search => '?dog'
|
search => '?dog'
|
||||||
hash => '#meow%22woof'
|
hash => '#meow%22woof'
|
||||||
|
new URL('/hello', 'file://friends/')
|
||||||
|
protocol => 'file:'
|
||||||
|
username => ''
|
||||||
|
password => ''
|
||||||
|
host => 'friends'
|
||||||
|
hostname => 'friends'
|
||||||
|
port => ''
|
||||||
|
pathname => '/hello'
|
||||||
|
search => ''
|
||||||
|
hash => ''
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
{ input: 'http://[1:1:0:0:1:0:0:0]/' },
|
{ input: 'http://[1:1:0:0:1:0:0:0]/' },
|
||||||
{ input: 'unknown://serenityos.org:0' },
|
{ input: 'unknown://serenityos.org:0' },
|
||||||
{ input: 'http://serenityos.org/cat?dog#meow"woof' },
|
{ input: 'http://serenityos.org/cat?dog#meow"woof' },
|
||||||
|
{ input: '/hello', base: 'file://friends/' },
|
||||||
]) {
|
]) {
|
||||||
printURL(url.input, url.base);
|
printURL(url.input, url.base);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue