fix(service-worker): let * match 0 characters in globs (#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 commit is contained in:
George Kalpakas
2018-04-12 23:34:43 +03:00
committed by Igor Minar
parent 08325aaffc
commit 6c2c95851a
3 changed files with 12 additions and 5 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
const WILD_SINGLE = '[^\\/]+';
const WILD_SINGLE = '[^\\/]*';
const WILD_OPEN = '(?:.+\\/)?';
const TO_ESCAPE = [