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
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

@ -163,7 +163,7 @@ Optional<u16> default_port_for_scheme(StringView scheme)
return {};
}
URL create_with_file_scheme(ByteString const& path, ByteString const& fragment, ByteString const& hostname)
Optional<URL> create_with_file_scheme(ByteString const& path, ByteString const& fragment, ByteString const& hostname)
{
LexicalPath lexical_path(path);
if (!lexical_path.is_absolute())
@ -180,11 +180,10 @@ URL create_with_file_scheme(ByteString const& path, ByteString const& fragment,
url_builder.append(fragment);
}
auto url = Parser::basic_parse(url_builder.string_view());
return url.has_value() ? url.release_value() : URL {};
return Parser::basic_parse(url_builder.string_view());
}
URL create_with_url_or_path(ByteString const& url_or_path)
Optional<URL> create_with_url_or_path(ByteString const& url_or_path)
{
auto url = Parser::basic_parse(url_or_path);
if (url.has_value())