Repository navigation
Conversation
|
You can preview 369967a at https://pr23339-369967a.ngbuilds.io/. |
369967a to
5e2542c
Compare
|
You can preview 5e2542c at https://pr23339-5e2542c.ngbuilds.io/. |
The ServiceWorker will redirect navigation requests that don't match any `asset` or `data` group to the specified index file. The rules for a request to be classified as a navigation request are as follows: 1. Its `mode` must be `navigation`. 2. It must accept a `text/html` response. 3. Its URL must match certain criteria (see below). By default, a navigation request can have any URL except for: 1. URLs containing `__`. 2. URLs to files (i.e. containing a file extension in the last path segment). While these rules are fine in many cases, sometimes it is desirable to configure different rules for the URLs of navigation requests (e.g. ignore specific URLs and pass them through to the server). This commit adds support for specifying an optional `navigationUrls` list in `ngsw-config.json`, which contains URLs or simple globs (currently only recognizing `!`, `*` and `**`). Only requests whose URLs match any of the positive URLs/patterns and none of the negative ones (i.e. URLs/patterns starting with `!`) will be considered navigation requests (and handled accordingly by the SW). (This is an alternative implementation to angular#23025.) Fixes angular#20404
In [glob patterns][1], the `*` wildcard is supposed to match 0 or more characters. For reference: - This is also how `*` works in other implementations, such as `.gitignore` files or Firebase hosting config. - Some popular JS implementations (e.g. [minimatch][2], [micromatch][3]) work differently, matching 1 or more character (but not 0). This commit "fixes" the minimal glob support in `@angular/service-worker` to allow `*` to also match 0 characters. [1]: https://en.wikipedia.org/wiki/Glob_%28programming%29 [2]: https://www.npmjs.com/package/minimatch [3]: https://www.npmjs.com/package/micromatch
5e2542c to
b5e94eb
Compare
|
You can preview b5e94eb at https://pr23339-b5e94eb.ngbuilds.io/. |
| // There is an assignment for this client already. | ||
| let hash = this.clientVersionMap.get(clientId) !; | ||
| const hash = this.clientVersionMap.get(clientId) !; | ||
| let appVersion = this.lookupVersionByHash(hash, 'assignVersion'); |
There was a problem hiding this comment.
This call can throw if the SW is not in an okay state to read this.versions (if this.state is not DriverReadyState.NORMAL. Let's guard this lookup so it only happens if the SW is in a normal state state.
There was a problem hiding this comment.
Discussed "offline". lookupVersionByHash() was called without checking the state anyway, so this PR does not change anything in that regard.
…23339) The ServiceWorker will redirect navigation requests that don't match any `asset` or `data` group to the specified index file. The rules for a request to be classified as a navigation request are as follows: 1. Its `mode` must be `navigation`. 2. It must accept a `text/html` response. 3. Its URL must match certain criteria (see below). By default, a navigation request can have any URL except for: 1. URLs containing `__`. 2. URLs to files (i.e. containing a file extension in the last path segment). While these rules are fine in many cases, sometimes it is desirable to configure different rules for the URLs of navigation requests (e.g. ignore specific URLs and pass them through to the server). This commit adds support for specifying an optional `navigationUrls` list in `ngsw-config.json`, which contains URLs or simple globs (currently only recognizing `!`, `*` and `**`). Only requests whose URLs match any of the positive URLs/patterns and none of the negative ones (i.e. URLs/patterns starting with `!`) will be considered navigation requests (and handled accordingly by the SW). (This is an alternative implementation to #23025.) Fixes #20404 PR Close #23339
In [glob patterns][1], the `*` wildcard is supposed to match 0 or more characters. For reference: - This is also how `*` works in other implementations, such as `.gitignore` files or Firebase hosting config. - Some popular JS implementations (e.g. [minimatch][2], [micromatch][3]) work differently, matching 1 or more character (but not 0). This commit "fixes" the minimal glob support in `@angular/service-worker` to allow `*` to also match 0 characters. [1]: https://en.wikipedia.org/wiki/Glob_%28programming%29 [2]: https://www.npmjs.com/package/minimatch [3]: https://www.npmjs.com/package/micromatch PR Close #23339
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |


PR Checklist
PR Type
What is the current behavior?
The ServiceWorker will redirect navigation requests that don't match any
assetordatagroup to the specified index file. The rules for a request to be classified as a navigation request are as follows:modemust benavigation.text/htmlresponse.By default, a navigation request can have any URL except for:
__.While thse rules are fine in many cases, sometimes it is desirable to configure different rules for the URLs of navigation requests (e.g. ignore specific URLs and pass them through to the server).
Issue Number: #20404
What is the new behavior?
It is now possible to specify an optional
navigationUrlslist inngsw-config.json, which contains URLs or simple globs (currently only recognizing!,*and**). Only requests whose URLs match any of the positive URLs/patterns and none of the negative ones (i.e. URLs/patterns starting with!) will be considered navigation requests (and handled accordingly by the SW).Does this PR introduce a breaking change?
Other information
This is an alternative implementation to #23025.
Fixes #20404.