mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-16 16:12:53 +00:00
AK+Everywhere: Use Optional for URLParser::parse's base_url parameter
This commit is contained in:
parent
38bdf4d159
commit
9915fa72fb
Notes:
sideshowbarker
2024-07-17 08:25:15 +09:00
Author: https://github.com/networkException
Commit: 9915fa72fb
Pull-request: https://github.com/SerenityOS/serenity/pull/18287
Reviewed-by: https://github.com/linusg
12 changed files with 31 additions and 32 deletions
|
@ -135,7 +135,7 @@ WebIDL::ExceptionOr<void> URL::set_protocol(String const& protocol)
|
|||
auto& vm = realm().vm();
|
||||
|
||||
// basic URL parse the given value, followed by U+003A (:), with this’s URL as url and scheme start state as state override.
|
||||
auto result_url = URLParser::parse(TRY_OR_THROW_OOM(vm, String::formatted("{}:", protocol)), nullptr, m_url, URLParser::State::SchemeStart);
|
||||
auto result_url = URLParser::parse(TRY_OR_THROW_OOM(vm, String::formatted("{}:", protocol)), {}, m_url, URLParser::State::SchemeStart);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
return {};
|
||||
|
@ -197,7 +197,7 @@ void URL::set_host(String const& host)
|
|||
if (m_url.cannot_be_a_base_url())
|
||||
return;
|
||||
// 2. Basic URL parse the given value with this’s URL as url and host state as state override.
|
||||
auto result_url = URLParser::parse(host, nullptr, m_url, URLParser::State::Host);
|
||||
auto result_url = URLParser::parse(host, {}, m_url, URLParser::State::Host);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ void URL::set_hostname(String const& hostname)
|
|||
if (m_url.cannot_be_a_base_url())
|
||||
return;
|
||||
// 2. Basic URL parse the given value with this’s URL as url and hostname state as state override.
|
||||
auto result_url = URLParser::parse(hostname, nullptr, m_url, URLParser::State::Hostname);
|
||||
auto result_url = URLParser::parse(hostname, {}, m_url, URLParser::State::Hostname);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ void URL::set_port(String const& port)
|
|||
}
|
||||
|
||||
// 3. Otherwise, basic URL parse the given value with this’s URL as url and port state as state override.
|
||||
auto result_url = URLParser::parse(port, nullptr, m_url, URLParser::State::Port);
|
||||
auto result_url = URLParser::parse(port, {}, m_url, URLParser::State::Port);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ void URL::set_pathname(String const& pathname)
|
|||
auto url = m_url; // We copy the URL here to follow other browser's behaviour of reverting the path change if the parse failed.
|
||||
url.set_paths({});
|
||||
// 3. Basic URL parse the given value with this’s URL as url and path start state as state override.
|
||||
auto result_url = URLParser::parse(pathname, nullptr, move(url), URLParser::State::PathStart);
|
||||
auto result_url = URLParser::parse(pathname, {}, move(url), URLParser::State::PathStart);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ WebIDL::ExceptionOr<void> URL::set_search(String const& search)
|
|||
auto url_copy = url; // We copy the URL here to follow other browser's behaviour of reverting the search change if the parse failed.
|
||||
url_copy.set_query(DeprecatedString::empty());
|
||||
// 4. Basic URL parse input with url as url and query state as state override.
|
||||
auto result_url = URLParser::parse(input, nullptr, move(url_copy), URLParser::State::Query);
|
||||
auto result_url = URLParser::parse(input, {}, move(url_copy), URLParser::State::Query);
|
||||
if (result_url.is_valid()) {
|
||||
m_url = move(result_url);
|
||||
// 5. Set this’s query object’s list to the result of parsing input.
|
||||
|
@ -348,7 +348,7 @@ void URL::set_hash(String const& hash)
|
|||
auto url = m_url; // We copy the URL here to follow other browser's behaviour of reverting the hash change if the parse failed.
|
||||
url.set_fragment(DeprecatedString::empty());
|
||||
// 4. Basic URL parse input with this’s URL as url and fragment state as state override.
|
||||
auto result_url = URLParser::parse(input, nullptr, move(url), URLParser::State::Fragment);
|
||||
auto result_url = URLParser::parse(input, {}, move(url), URLParser::State::Fragment);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue