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

Allow NavigationRoute whitelisting/blacklisting to work with search parameters #631

Closed
mikefowler opened this issue Jun 14, 2017 · 1 comment
Assignees

Comments

@mikefowler
Copy link

Library Affected:
workbox-routing

Browser & Platform:
n/a

Issue or Feature Request Description:
It would be nice if NavigationRoute's whitelist and blacklist options supported matching on url.pathname + url.search instead of just on url.pathname. Performing server-based redirects based on a query parameter seems somewhat common, and such a redirect breaks if we can't specify that an app shell should not be served for URLs containing that query parameter.

Take the following route that we've implemented:

workboxSW.router.registerNavigationRoute(APP_SHELL_ROUTE, {
  whitelist: [
    /^\/$/,
  ],
});

On the page, a user can change languages. The language picker redirects the browser to the current URL but with locale=de appended to the search query. Normally the server would intercept these requests and 302 redirect to de.domain.com. With a service worker installed and the above NavigationRoute registered, this redirect breaks; the user is served the app shell as usual and no redirect occurs.

It makes sense to me that we should be able to do the following:

workboxSW.router.registerNavigationRoute(APP_SHELL_ROUTE, {
  whitelist: [
    /^\/$/,
  ],
  blacklist: [
    /[&?]locale=/,
  ],
});

Thoughts?

@jeffposnick
Copy link
Contributor

Sounds reasonable to me.

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

No branches or pull requests

2 participants