Re: [w3c/ServiceWorker] Declarative routing (#1373)

@jeffposnick 

> Developers sometimes want to route cross-origin requests. And sometimes they don't.

```js
router.add(
  [
    new RouterIfURLStarts('https://photos.example.com/'),
    new RouterIfURLEnds('.jpg', { ignoreSearch: true }),
  ]
  // …
);
```

The above would match on URLs that start `https://photos.example.com/` and end `.jpg`. It gets trickier if you want to match URLs to all other origins that end `.jpg`, you'd need `RouterNot` for that.

RegExp is tricky here as there's no spec for how it could outlive JavaScript. We could try and standardise globbing, but I worry that would take a big chunk of time.

> Non-200 OK responses sometimes need to be treated as errors

I've added `rejectNotOk` as an option. Terrible name, but that's something we can bikeshed.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1373#issuecomment-451953139

Received on Monday, 7 January 2019 14:32:48 UTC