Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer matchCallbacks to RegExpRoutes in the docs #2486

Closed
jeffposnick opened this issue May 1, 2020 · 1 comment · Fixed by google/WebFundamentals#8680
Closed

Prefer matchCallbacks to RegExpRoutes in the docs #2486

jeffposnick opened this issue May 1, 2020 · 1 comment · Fixed by google/WebFundamentals#8680
Labels

Comments

@jeffposnick
Copy link
Contributor

Pretty much universally throughout our docs and samples, we end up using RegExps for routing.

In retrospect, this ends up being fairly confusing and error prone, especially since we have to explain the nuances around cross-origin RegExp routing.

We should audit the current examples in the docs and when it makes sense to switch to a simple matchCallback, do so.

E.g.

registerRoute(
  /^https:\/\/fonts\.googleapis\.com/,
  new StaleWhileRevalidate({
    cacheName: 'google-fonts-stylesheets',
  })
);

makes much more sense as

registerRoute(
  ({url}) => url.origin === 'https://fonts.googleapis.com',
  new StaleWhileRevalidate({
    cacheName: 'google-fonts-stylesheets',
  })
);
@jeffposnick
Copy link
Contributor Author

Fixed by google/WebFundamentals#8680

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant