Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Since USVString does not pattern match with URLs with query strings or hashtags, the example code has been changed to patterns without them.
Also, the short-hand form is under the discussion in whatwg/urlpattern#182, I intend to avoid the examples affected by the result.
  • Loading branch information
yoshisatoyanagisawa authored Sep 14, 2023
1 parent bfbfe3d commit ffff095
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,29 +97,28 @@ enum RouterSourceEnum { "network" };
#### Bypassing ServiceWorker for particular resources

```js
// Go straight to the network and bypass invoking "fetch" handlers for all same-origin URLs that start
// with '/form/'.
// Go straight to the network and bypass invoking "fetch" handlers for URLs that start with '/form/'.
addEventListener('install', (event) => {
event.registerRouter({
condition: {
urlPattern: "/form/*"
urlPattern: new URLPattern({pathname: "/form/*"})
},
source: "network"
});
})

// Go straight to the network and bypass invoking "fetch" handlers for all same-origin URLs that start
// Go straight to the network and bypass invoking "fetch" handlers for URLs that start
// with '/videos/' and '/images/'.
addEventListener('install', (event) => {
event.registerRouter([{
condition: {
urlPattern: "/images/*"
urlPattern: new URLPattern({pathname: "/images/*"})
},
source: "network"
},
{
condition: {
urlPattern: "/videos/*"
urlPattern: new URLPattern({pathname: "/videos/*"})
},
source: "network"
}]);
Expand Down

0 comments on commit ffff095

Please sign in to comment.