1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

LibWeb: Add interface for 'concept-url-parser'

This does not implement extra functionality on top of the basic parser,
but allows multiple places in LibWeb to call the 'correct' interface for
when it is fully implemented.
This commit is contained in:
Shannon Booth 2023-07-15 14:24:58 +12:00 committed by Andreas Kling
parent 7ef4689383
commit 6fecd8cc44
6 changed files with 37 additions and 11 deletions

View file

@ -490,4 +490,27 @@ bool host_is_domain(StringView host)
&& !IPv6Address::from_string(host).has_value();
}
// https://url.spec.whatwg.org/#concept-url-parser
AK::URL parse(StringView input, Optional<AK::URL> const& base_url)
{
// FIXME: We should probably have an extended version of AK::URL for LibWeb instead of standalone functions like this.
// 1. Let url be the result of running the basic URL parser on input with base and encoding.
auto url = URLParser::basic_parse(input, base_url);
// 2. If url is failure, return failure.
if (url.is_valid())
return {};
// 3. If urls scheme is not "blob",
if (url.scheme() != "blob")
return url;
// FIXME: 4. Set urls blob URL entry to the result of resolving the blob URL url,
// FIXME: 5. if that did not return failure, and null otherwise.
// 6. Return url
return url;
}
}