mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
AK+Everywhere: Use Optional for URLParser::parse's base_url parameter
This commit is contained in:
parent
38bdf4d159
commit
9915fa72fb
12 changed files with 31 additions and 32 deletions
|
@ -80,7 +80,7 @@ void HTMLHyperlinkElementUtils::set_protocol(DeprecatedString protocol)
|
|||
return;
|
||||
|
||||
// 3. Basic URL parse the given value, followed by ":", with this element's url as url and scheme start state as state override.
|
||||
auto result_url = URLParser::parse(DeprecatedString::formatted("{}:", protocol), nullptr, m_url, URLParser::State::SchemeStart);
|
||||
auto result_url = URLParser::parse(DeprecatedString::formatted("{}:", protocol), {}, m_url, URLParser::State::SchemeStart);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
|
||||
|
@ -194,7 +194,7 @@ void HTMLHyperlinkElementUtils::set_host(DeprecatedString host)
|
|||
return;
|
||||
|
||||
// 4. Basic URL parse the given value, with url as url and host state as state override.
|
||||
auto result_url = URLParser::parse(host, nullptr, url, URLParser::State::Host);
|
||||
auto result_url = URLParser::parse(host, {}, url, URLParser::State::Host);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
|
||||
|
@ -227,7 +227,7 @@ void HTMLHyperlinkElementUtils::set_hostname(DeprecatedString hostname)
|
|||
return;
|
||||
|
||||
// 4. Basic URL parse the given value, with 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);
|
||||
|
||||
|
@ -269,7 +269,7 @@ void HTMLHyperlinkElementUtils::set_port(DeprecatedString port)
|
|||
m_url->set_port({});
|
||||
} else {
|
||||
// 5. Otherwise, basic URL parse the given value, with 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);
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ void HTMLHyperlinkElementUtils::set_pathname(DeprecatedString pathname)
|
|||
url->set_paths({});
|
||||
|
||||
// 5. Basic URL parse the given value, with 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);
|
||||
|
||||
|
@ -360,7 +360,7 @@ void HTMLHyperlinkElementUtils::set_search(DeprecatedString search)
|
|||
url_copy->set_query(DeprecatedString::empty());
|
||||
|
||||
// 3. Basic URL parse input, with null, this element's node document's document's character encoding, 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);
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ void HTMLHyperlinkElementUtils::set_hash(DeprecatedString hash)
|
|||
url_copy->set_fragment(DeprecatedString::empty());
|
||||
|
||||
// 3. Basic URL parse input, with url as url and fragment state as state override.
|
||||
auto result_url = URLParser::parse(input, nullptr, move(url_copy), URLParser::State::Fragment);
|
||||
auto result_url = URLParser::parse(input, {}, move(url_copy), URLParser::State::Fragment);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ WebIDL::ExceptionOr<void> Location::set_hash(String const& value)
|
|||
copy_url.set_fragment("");
|
||||
|
||||
// 6. Basic URL parse input, with copyURL as url and fragment state as state override.
|
||||
auto result_url = URLParser::parse(input, nullptr, copy_url, URLParser::State::Fragment);
|
||||
auto result_url = URLParser::parse(input, {}, copy_url, URLParser::State::Fragment);
|
||||
|
||||
// 7. If copyURL's fragment is this's url's fragment, then return.
|
||||
if (copy_url.fragment() == this->url().fragment())
|
||||
|
|
|
@ -159,7 +159,7 @@ WebIDL::ExceptionOr<Optional<AK::URL>> resolve_imports_match(DeprecatedString co
|
|||
VERIFY(resolution_result->serialize().ends_with("/"sv));
|
||||
|
||||
// 5. Let url be the result of URL parsing afterPrefix with resolutionResult.
|
||||
auto url = URLParser::parse(after_prefix, &*resolution_result);
|
||||
auto url = URLParser::parse(after_prefix, *resolution_result);
|
||||
|
||||
// 6. If url is failure, then throw a TypeError indicating that resolution of normalizedSpecifier was blocked since the afterPrefix portion
|
||||
// could not be URL-parsed relative to the resolutionResult mapped to by the specifierKey prefix.
|
||||
|
@ -189,7 +189,7 @@ Optional<AK::URL> resolve_url_like_module_specifier(DeprecatedString const& spec
|
|||
// 1. If specifier starts with "/", "./", or "../", then:
|
||||
if (specifier.starts_with("/"sv) || specifier.starts_with("./"sv) || specifier.starts_with("../"sv)) {
|
||||
// 1. Let url be the result of URL parsing specifier with baseURL.
|
||||
auto url = URLParser::parse(specifier, &base_url);
|
||||
auto url = URLParser::parse(specifier, base_url);
|
||||
|
||||
// 2. If url is failure, then return null.
|
||||
if (!url.is_valid())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue