How to use the workbox-routing/Route.js.Route function in workbox-routing

To help you get started, we’ve selected a few workbox-routing 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 GoogleChrome / workbox / packages / workbox-google-analytics / src / initialize.ts View on Github external
const createCollectRoutes = (bgSyncPlugin: BackgroundSyncPlugin) => {
  const match = ({url}: RouteMatchCallbackOptions) =>
      url.hostname === GOOGLE_ANALYTICS_HOST &&
      COLLECT_PATHS_REGEX.test(url.pathname);

  const handler = new NetworkOnly({
    plugins: [bgSyncPlugin],
  });

  return [
    new Route(match, handler, 'GET'),
    new Route(match, handler, 'POST'),
  ];
};
github GoogleChrome / workbox / packages / workbox-google-analytics / src / initialize.ts View on Github external
const createCollectRoutes = (bgSyncPlugin: BackgroundSyncPlugin) => {
  const match = ({url}: RouteMatchCallbackOptions) =>
      url.hostname === GOOGLE_ANALYTICS_HOST &&
      COLLECT_PATHS_REGEX.test(url.pathname);

  const handler = new NetworkOnly({
    plugins: [bgSyncPlugin],
  });

  return [
    new Route(match, handler, 'GET'),
    new Route(match, handler, 'POST'),
  ];
};
github GoogleChrome / workbox / packages / workbox-google-analytics / src / initialize.ts View on Github external
const createGtmJsRoute = (cacheName: string) => {
  const match = ({url}: RouteMatchCallbackOptions) =>
      url.hostname === GTM_HOST &&
      url.pathname === GTM_JS_PATH;

  const handler = new NetworkFirst({cacheName});

  return new Route(match, handler, 'GET');
};

workbox-routing

A service worker helper library to route request URLs to handlers.

MIT
Latest version published 29 days ago

Package Health Score

97 / 100
Full package analysis