mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +00:00
LibWeb: Implement URL.parse
This was an addition to the URL spec, see: https://github.com/whatwg/url/commit/58acb0
This commit is contained in:
parent
67ea56da59
commit
9b6a1de777
Notes:
sideshowbarker
2024-07-16 23:03:06 +09:00
Author: https://github.com/shannonbooth
Commit: 9b6a1de777
Pull-request: https://github.com/SerenityOS/serenity/pull/24309
5 changed files with 123 additions and 10 deletions
|
@ -70,6 +70,24 @@ JS::NonnullGCPtr<DOMURL> DOMURL::initialize_a_url(JS::Realm& realm, URL::URL con
|
|||
return result_url;
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-url-parse
|
||||
JS::GCPtr<DOMURL> DOMURL::parse_for_bindings(JS::VM& vm, String const& url, Optional<String> const& base)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. Let parsedURL be the result of running the API URL parser on url with base, if given.
|
||||
auto parsed_url = parse_api_url(url, base);
|
||||
|
||||
// 2. If parsedURL is failure, then return null.
|
||||
if (!parsed_url.has_value())
|
||||
return nullptr;
|
||||
|
||||
// 3. Let url be a new URL object.
|
||||
// 4. Initialize url with parsedURL.
|
||||
// 5. Return url.
|
||||
return initialize_a_url(realm, parsed_url.value());
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-url-url
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMURL>> DOMURL::construct_impl(JS::Realm& realm, String const& url, Optional<String> const& base)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue