How to use the @angular/service-worker/worker.UrlMatcher function in @angular/service-worker

To help you get started, we’ve selected a few @angular/service-worker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / mobile-toolkit / service-worker / worker / src / plugins / routes / index.ts View on Github external
const matchesRoutingTable = Object.keys(manifest.routes).some(route => {
      const config = manifest.routes[route];
      if (config['match']) {
        const matcher = new UrlMatcher(route, config as UrlConfig, this.worker.adapter.scope);
        return matcher.matches(req.url);
      } else {
        const oldConfig = config as RouteConfig;
        const matchesPath = oldConfig.prefix
          ? path.indexOf(route) === 0
          : path === route;
        const matchesPathAndExtension = matchesPath &&
            (!oldConfig.onlyWithoutExtension || !this.hasExtension(path));
        return matchesPathAndExtension;
      }
    });
    if (matchesRoutingTable) {