LibWeb: Return OptionalNone from DOMURL::parse on failure

This ports one more function away from needing to use the awkward
valid state of the URL class.
This commit is contained in:
Shannon Booth 2025-01-22 17:35:52 +13:00 committed by Sam Atkins
commit fd27eef0d1
Notes: github-actions[bot] 2025-01-22 12:34:57 +00:00
18 changed files with 63 additions and 65 deletions

View file

@ -302,7 +302,7 @@ static void update(JS::VM& vm, GC::Ref<Job> job)
auto resolved_scope = DOMURL::parse("./"sv, job->script_url);
// 2. Set maxScopeString to "/", followed by the strings in resolvedScopes path (including empty strings), separated from each other by "/".
max_scope_string = join_paths_with_slash(resolved_scope);
max_scope_string = join_paths_with_slash(*resolved_scope);
}
// 14. Else:
else {
@ -310,9 +310,9 @@ static void update(JS::VM& vm, GC::Ref<Job> job)
auto max_scope = DOMURL::parse(service_worker_allowed.get<Vector<ByteBuffer>>()[0], job->script_url);
// 2. If maxScopes origin is jobs script url's origin, then:
if (max_scope.origin().is_same_origin(job->script_url.origin())) {
if (max_scope->origin().is_same_origin(job->script_url.origin())) {
// 1. Set maxScopeString to "/", followed by the strings in maxScopes path (including empty strings), separated from each other by "/".
max_scope_string = join_paths_with_slash(max_scope);
max_scope_string = join_paths_with_slash(*max_scope);
}
}