mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibURL: Implement create_with_file_scheme using URL Parser
Creating a URL should almost always go through the URLParser to handle all of the small edge cases involved. This reduces the need for URL valid state.
This commit is contained in:
parent
9c758e5f65
commit
2072eee83d
Notes:
github-actions[bot]
2025-04-19 11:20:23 +00:00
Author: https://github.com/shannonbooth
Commit: 2072eee83d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4401
Reviewed-by: https://github.com/trflynn89 ✅
4 changed files with 17 additions and 13 deletions
|
@ -45,11 +45,11 @@ Optional<URL::URL> sanitize_url(StringView location, Optional<SearchEngine> cons
|
|||
}
|
||||
|
||||
static constexpr Array SUPPORTED_SCHEMES { "about"sv, "data"sv, "file"sv, "http"sv, "https"sv, "resource"sv };
|
||||
if (!any_of(SUPPORTED_SCHEMES, [&](StringView const& scheme) { return scheme == url.scheme(); }))
|
||||
if (!any_of(SUPPORTED_SCHEMES, [&](StringView const& scheme) { return scheme == url->scheme(); }))
|
||||
return search_url_or_error();
|
||||
// FIXME: Add support for other schemes, e.g. "mailto:". Firefox and Chrome open mailto: locations.
|
||||
|
||||
auto const& host = url.host();
|
||||
auto const& host = url->host();
|
||||
if (host.has_value() && host->is_domain()) {
|
||||
auto const& domain = host->get<String>();
|
||||
|
||||
|
@ -64,7 +64,7 @@ Optional<URL::URL> sanitize_url(StringView location, Optional<SearchEngine> cons
|
|||
auto public_suffix = URL::get_public_suffix(domain);
|
||||
if (!public_suffix.has_value() || *public_suffix == domain) {
|
||||
if (append_tld == AppendTLD::Yes)
|
||||
url.set_host(MUST(String::formatted("{}.com", domain)));
|
||||
url->set_host(MUST(String::formatted("{}.com", domain)));
|
||||
else if (https_scheme_was_guessed && domain != "localhost"sv)
|
||||
return search_url_or_error();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue