LibWeb: Support parsing a URL relative to environment settings object

This commit is contained in:
Idan Horowitz 2022-11-15 01:53:22 +02:00 committed by Linus Groh
parent f69c135796
commit efe94d9040
Notes: sideshowbarker 2024-07-17 04:26:50 +09:00
2 changed files with 18 additions and 0 deletions

View file

@ -151,6 +151,22 @@ void EnvironmentSettingsObject::prepare_to_run_callback()
context->skip_when_determining_incumbent_counter++;
}
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url
AK::URL EnvironmentSettingsObject::parse_url(StringView url)
{
// 1. Let encoding be document's character encoding, if document was given, and environment settings object's API URL character encoding otherwise.
// FIXME: Pass in environment settings object's API URL character encoding.
// 2. Let baseURL be document's base URL, if document was given, and environment settings object's API base URL otherwise.
auto base_url = api_base_url();
// 3. Let urlRecord be the result of applying the URL parser to url, with baseURL and encoding.
// 4. If urlRecord is failure, then return failure.
// 5. Let urlString be the result of applying the URL serializer to urlRecord.
// 6. Return urlString as the resulting URL string and urlRecord as the resulting URL record.
return base_url.complete_url(url);
}
// https://html.spec.whatwg.org/multipage/webappapis.html#clean-up-after-running-a-callback
void EnvironmentSettingsObject::clean_up_after_running_callback()
{