Skip to content

Commit 2c6fa22

Browse files
Fixing max scope to include trailing slash. (#1424)
* Fixing max scope to include trailing slash. * Making use of base URL clearer * Updating call to parse, and adding trailing slash note.
1 parent 4a50271 commit 2c6fa22

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

docs/index.bs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,12 +2502,16 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
25022502
1. Let |scopeURL| be |registration|'s [=service worker registration/scope url=].
25032503
1. Let |maxScopeString| be null.
25042504
1. If |serviceWorkerAllowed| is null, then:
2505-
1. Set |maxScopeString| to "<code>/</code>" concatenated with the strings, except the last string that denotes the script's file name, in |job|'s [=job/script url=]'s [=url/path=] (including empty strings), separated from each other by "<code>/</code>".
2505+
1. Let |resolvedScope| be the result of [=URL parser|parsing=] "`./`" using |job|'s [=job/script url=] as the [=base URL=].
2506+
1. Set |maxScopeString| to "`/`", followed by the strings in |resolvedScope|'s [=url/path=] (including empty strings), separated from each other by "`/`".
2507+
2508+
Note: The final item in |resolvedScope|'s [=url/path=] will always be an empty string, so |maxScopeString| will have a trailing "`/`".
2509+
25062510
1. Else:
2507-
1. Let |maxScope| be the result of <a lt="URL parser">parsing</a> |serviceWorkerAllowed| with |job|'s [=job/script url=].
2511+
1. Let |maxScope| be the result of [=URL parser|parsing=] |serviceWorkerAllowed| using |job|'s [=job/script url=] as the [=base URL=].
25082512
1. If |maxScope|'s [=url/origin=] is |job|'s [=job/script url=]'s [=url/origin=], then:
2509-
1. Set |maxScopeString| to "<code>/</code>" concatenated with the strings in |maxScope|'s [=url/path=] (including empty strings), separated from each other by "<code>/</code>".
2510-
1. Let |scopeString| be "<code>/</code>" concatenated with the strings in |scopeURL|'s [=url/path=] (including empty strings), separated from each other by "<code>/</code>".
2513+
1. Set |maxScopeString| to "`/`", followed by the strings in |maxScope|'s [=url/path=] (including empty strings), separated from each other by "`/`".
2514+
1. Let |scopeString| be "`/`", followed by the strings in |scopeURL|'s [=url/path=] (including empty strings), separated from each other by "`/`".
25112515
1. If |maxScopeString| is null or |scopeString| does not start with |maxScopeString|, then:
25122516
1. Invoke [=Reject Job Promise=] with |job| and "{{SecurityError}}" {{DOMException}}.
25132517
1. Asynchronously complete these steps with a <a>network error</a>.

docs/v1/index.bs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,12 +2334,16 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
23342334
1. Let |scopeURL| be |registration|'s [=service worker registration/scope url=].
23352335
1. Let |maxScopeString| be null.
23362336
1. If |serviceWorkerAllowed| is null, then:
2337-
1. Set |maxScopeString| to "<code>/</code>" concatenated with the strings, except the last string that denotes the script's file name, in |job|'s [=job/script url=]'s [=url/path=] (including empty strings), separated from each other by "<code>/</code>".
2337+
1. Let |resolvedScope| be the result of [=URL parser|parsing=] "`./`" using |job|'s [=job/script url=] as the [=base URL=].
2338+
1. Set |maxScopeString| to "`/`", followed by the strings in |resolvedScope|'s [=url/path=] (including empty strings), separated from each other by "`/`".
2339+
2340+
Note: The final item in |resolvedScope|'s [=url/path=] will always be an empty string, so |maxScopeString| will have a trailing "`/`".
2341+
23382342
1. Else:
2339-
1. Let |maxScope| be the result of <a lt="URL parser">parsing</a> |serviceWorkerAllowed| with |job|'s [=job/script url=].
2343+
1. Let |maxScope| be the result of [=URL parser|parsing=] |serviceWorkerAllowed| using |job|'s [=job/script url=] as the [=base URL=].
23402344
1. If |maxScope|'s [=url/origin=] is |job|'s [=job/script url=]'s [=url/origin=], then:
2341-
1. Set |maxScopeString| to "<code>/</code>" concatenated with the strings in |maxScope|'s [=url/path=] (including empty strings), separated from each other by "<code>/</code>".
2342-
1. Let |scopeString| be "<code>/</code>" concatenated with the strings in |scopeURL|'s [=url/path=] (including empty strings), separated from each other by "<code>/</code>".
2345+
1. Set |maxScopeString| to "`/`", followed by the strings in |maxScope|'s [=url/path=] (including empty strings), separated from each other by "`/`".
2346+
1. Let |scopeString| be "`/`", followed by the strings in |scopeURL|'s [=url/path=] (including empty strings), separated from each other by "`/`".
23432347
1. If |maxScopeString| is null or |scopeString| does not start with |maxScopeString|, then:
23442348
1. Invoke [=Reject Job Promise=] with |job| and "{{SecurityError}}" {{DOMException}}.
23452349
1. Asynchronously complete these steps with a <a>network error</a>.

0 commit comments

Comments
 (0)