fix(service-worker): navigation urls backwards compatibility (#27244)

PR Close #27244
This commit is contained in:
Serginho
2019-01-15 13:10:37 +01:00
committed by Andrew Kushnir
parent 2e5752eb06
commit d49d1e7d73
2 changed files with 51 additions and 1 deletions

View File

@ -15,6 +15,12 @@ import {IdleScheduler} from './idle';
import {Manifest} from './manifest';
const BACKWARDS_COMPATIBILITY_NAVIGATION_URLS = [
{positive: true, regex: '^/.*$'},
{positive: false, regex: '^/.*\\.[^/]*$'},
{positive: false, regex: '^/.*__'},
];
/**
* A specific version of the application, identified by a unique manifest
* as determined by its hash.
@ -85,6 +91,10 @@ export class AppVersion implements UpdateSource {
this.scope, this.adapter, config, this.database,
`ngsw:${config.version}:data`));
// This keeps backwards compatibility with app versions without navigation urls.
// Fix: https://github.com/angular/angular/issues/27209
manifest.navigationUrls = manifest.navigationUrls || BACKWARDS_COMPATIBILITY_NAVIGATION_URLS;
// Create `include`/`exclude` RegExps for the `navigationUrls` declared in the manifest.
const includeUrls = manifest.navigationUrls.filter(spec => spec.positive);
const excludeUrls = manifest.navigationUrls.filter(spec => !spec.positive);