Skip to content

Commit bdc2474

Browse files
Introduce changes upon whatwg/urlpattern#199.
1 parent 0a553af commit bdc2474

File tree

1 file changed

+11
-50
lines changed

1 file changed

+11
-50
lines changed

docs/index.bs

+11-50
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/
15691569
<pre class="idl">
15701570
[Exposed=ServiceWorker]
15711571
interface InstallEvent : ExtendableEvent {
1572-
Promise&lt;undefined&gt; registerRouter((RouterRule or sequence&lt;RouterRule&gt;) rules);
1572+
Promise&lt;undefined&gt; addRoutes((RouterRule or sequence&lt;RouterRule&gt;) rules);
15731573
};
15741574

15751575
dictionary RouterRule {
@@ -1578,24 +1578,24 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/
15781578
};
15791579

15801580
dictionary RouterCondition {
1581-
USVString urlPattern;
1581+
URLPatternCompatible urlPattern;
15821582
};
15831583

1584-
enum RouterSourceEnum { "network" };
1584+
enum RouterSource { "network" };
15851585
</pre>
15861586

15871587
Each {{RouterCondition/urlPattern}} object has an associated <dfn>URLPattern</dfn>, a {{URLPattern}}, which is initially unset.
15881588

15891589
<section>
1590-
<h4 id="register-router-method">{{InstallEvent/registerRouter(rules)|event.registerRouter(rules)}}</h4>
1590+
<h4 id="register-router-method">{{InstallEvent/addRoutes(rules)|event.addRoutes(rules)}}</h4>
15911591

1592-
{{InstallEvent/registerRouter(rules)}} registers this service worker the rules to offload simple tasks that the fetch handler does.
1592+
{{InstallEvent/addRoutes(rules)}} registers this service worker the rules to offload simple tasks that the fetch handler does.
15931593

1594-
<dfn method for="InstallEvent"><code>registerRouter(|rules|)</code></dfn> method *must* run these steps:
1594+
<dfn method for="InstallEvent"><code>addRoutes(|rules|)</code></dfn> method *must* run these steps:
15951595

15961596
1. Let |routerRules| be a list of {{RouterRule}} dictionaries.
15971597
1. If |rules| is a {{RouterRule}} dictionary, set |rules| to &#x00AB; |rules| &#x00BB;.
1598-
1. for each |rule| in |rules|:
1598+
1. For each |rule| of |rules|:
15991599
1. If running [=VerifyRouterRule=] algorithm with |rule| and [=/service worker=] returns false, <a>throw</a> a <code>TypeError</code>.
16001600
1. Append |rule| to |routerRules|.
16011601
1. Set [=/service worker=]'s [=static router rules object=] to |routerRules|.
@@ -3244,52 +3244,13 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/
32443244
: Output
32453245
:: a boolean
32463246

3247-
1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] is the empty string, return false.
32483247
1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"].
3249-
1. If |rawPattern| is a [=string=], then:
3250-
1. Let |baseURL| be |serviceWorker|'s [=service worker/script url=].
3251-
1. Set |pattern| to the result of constructing a {{URLPattern}} using the {{URLPattern/URLPattern(input, baseURL)}} constructor steps given |rawPattern| and |baseURL|. If those steps throw, catch the exception and return false.
3252-
1. Otherwise, if |rawPattern| is {{URLPatternInit}}:
3253-
1. Set |pattern| to the result of constructing a {{URLPattern}} using the {{URLPattern/URLPattern(input)}} constructor steps given |rawPattern|. If those steps throw, catch the exception and return false.
3254-
1. Otherwise, return false.
3255-
1. If running the [=VerifyURLPattern=] algorithm with |pattern| returns false, return false.
3256-
1. Set |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]'s associated {{URLPattern}} to |pattern|.
3257-
1. Return true.
3258-
</section>
3259-
3260-
<section algorithm>
3261-
<h3 id="verify-urlpattern-algorithm"><dfn>VerifyURLPattern</dfn></h3>
3262-
3263-
: Input
3264-
:: |pattern|, a {{URLPattern}}
3265-
: Output
3266-
:: a boolean
3267-
3268-
1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/protocol component=] returns false, return false.
3269-
1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/username component=] returns false, return false.
3270-
1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/password component=] returns false, return false.
3271-
1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/hostname component=] returns false, return false.
3272-
1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/port component=] returns false, return false.
3273-
1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/pathname component=] returns false, return false.
3274-
1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/search component=] returns false, return false.
3275-
1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/hash component=] returns false, return false.
3276-
1. Return true.
3277-
</section>
3248+
1. Let |pattern| be the result of [=building a URLPattern from a Web IDL value=] |rawPattern| given |baseURL| and |serivceWorker|'s [=service worker/global object=]'s [=relevant realm=]. If this throws an exception, catch it and return false.
3249+
1. If |pattern| [=URLPattern/has regexp groups=] returns true, return false.
32783250

3279-
<section algorithm>
3280-
<h3 id="verify-urlpattern-component-algorithm"><dfn>VerifyURLPatternComponent</dfn></h3>
3281-
3282-
: Input
3283-
:: |component|, a [=component=].
3284-
: Output
3285-
:: a boolean
3286-
3287-
1. Let |parts| be a result of [=urlpattern/parsing=] |component|'s associated [=urlpattern-component/pattern string=].
3288-
1. [=list/For each=] |part| of |parts|:
3289-
1. If |part|'s [=urlpattern-part/type=] is "<code>regexp</code>", return false.
3290-
3291-
Note: Since running a user-defined regular expression has a security concern, it is prohibited.
3251+
Note: Since running a user-defined regular expression has a security concern, it is prohibited.
32923252

3253+
1. Set |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]'s associated {{URLPattern}} to |pattern|.
32933254
1. Return true.
32943255
</section>
32953256

0 commit comments

Comments
 (0)