LibURL: Port create_with_file_scheme to Optional

Removing one of the main remaining users of URL valid state.
This commit is contained in:
Shannon Booth 2025-04-19 16:43:17 +12:00 committed by Tim Flynn
parent 2072eee83d
commit 00bbb2105b
Notes: github-actions[bot] 2025-04-19 11:20:14 +00:00
5 changed files with 18 additions and 16 deletions

View file

@ -35,10 +35,10 @@ Optional<URL::URL> sanitize_url(StringView location, Optional<SearchEngine> cons
auto url = URL::create_with_url_or_path(location);
if (!url.is_valid()) {
if (!url.has_value()) {
url = URL::create_with_url_or_path(ByteString::formatted("https://{}", location));
if (!url.is_valid())
if (!url.has_value())
return search_url_or_error();
https_scheme_was_guessed = true;
@ -140,9 +140,10 @@ static URLParts break_web_url_into_parts(URL::URL const& url, StringView url_str
Optional<URLParts> break_url_into_parts(StringView url_string)
{
auto url = URL::create_with_url_or_path(url_string);
if (!url.is_valid())
auto maybe_url = URL::create_with_url_or_path(url_string);
if (!maybe_url.has_value())
return {};
auto const& url = maybe_url.value();
auto const& scheme = url.scheme();
auto scheme_length = scheme.bytes_as_string_view().length();