LibWeb: Remove extraneous trailing '/' from service worker script scope

The spec language specifies 'Set maxScopeString to "/", followed by the
strings in XXXX’s path (including empty strings), separated from each
other by "/"': That is, adjacent components are separated by a '/', but
the last component does not get a trailing '/'.

This resulted in the generated scope string ending with '//' in some
cases, incorrectly tripping the 'Service-Worker-Allowed' security check
This commit is contained in:
Idan Horowitz 2025-08-05 00:01:21 +03:00 committed by Jelle Raaijmakers
parent 56852fb5c2
commit e2fe46065a

View File

@ -289,10 +289,7 @@ static void update(JS::VM& vm, GC::Ref<Job> job)
auto join_paths_with_slash = [](URL::URL const& url) -> ByteString {
StringBuilder builder;
builder.append('/');
for (auto const& component : url.paths()) {
builder.append(component);
builder.append('/');
}
builder.join('/', url.paths());
return builder.to_byte_string();
};