Everywhere: Remove some use of the URL constructors

These make it too easy to construct an invalid URL, which makes it
difficult to remove the valid state of URL - which this API relies
on.
This commit is contained in:
Shannon Booth 2025-02-16 14:45:52 +13:00 committed by Tim Flynn
commit d62cf0a807
Notes: github-actions[bot] 2025-02-19 13:02:46 +00:00
11 changed files with 341 additions and 329 deletions

View file

@ -193,9 +193,9 @@ URL create_with_file_scheme(ByteString const& path, ByteString const& fragment,
URL create_with_url_or_path(ByteString const& url_or_path)
{
URL url = url_or_path;
if (url.is_valid())
return url;
auto url = Parser::basic_parse(url_or_path);
if (url.has_value())
return url.release_value();
ByteString path = LexicalPath::canonicalized_path(url_or_path);
return create_with_file_scheme(path);