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

Using ignoreUrlParametersMatching has a bug when testing with directoryIndex #758

Closed
emadzz opened this issue Aug 21, 2017 · 3 comments · Fixed by #762
Closed

Using ignoreUrlParametersMatching has a bug when testing with directoryIndex #758

emadzz opened this issue Aug 21, 2017 · 3 comments · Fixed by #762
Assignees
Labels
Bug An issue with our existing, production codebase.

Comments

@emadzz
Copy link

emadzz commented Aug 21, 2017

Library Affected:
workbox-sw

Browser & Platform:
all browsers

Issue or Feature Request Description:
Issue: using option ignoreUrlParametersMatching does not work as expected.

Expected behavior is for the service-worker to serve the following urls //localhost/ & //localhost/?launcher=true. But //localhost/?launcher=true doesn't get served from cache despite the launcher parameter being added to be ignored.

Used options:

new self.WorkboxSW({
  "skipWaiting": true,
  "ignoreUrlParametersMatching": [/launcher/]
});

I believe this is a bug with the capture function which tries to add the directoryIndex and test against the original url instead of the strippedUrl.

Suspected culprit line is: https://github.com/GoogleChrome/workbox/blob/master/packages/workbox-sw/src/lib/workbox-sw.js#L329

When reporting bugs, please include relevant JavaScript Console logs and links to public URLs at which the issue could be reproduced.
N/A

@addyosmani
Copy link
Member

I believe this is a bug with the capture function which tries to add the directoryIndex and test against the original url instead of the strippedUrl.

If launcher=true isn't being ignored by ignoreUrlParametersMatching, that does appear to be an issue with the current capture logic. cc @jeffposnick for a sanity check

@addyosmani addyosmani added Discuss An open question, where input from the community would be appreciated. question labels Aug 21, 2017
@emadzz
Copy link
Author

emadzz commented Aug 21, 2017

I can confirm again, that launcher, launcher=true are not being ignored by ignoreUrlParametersMatching.

@jeffposnick
Copy link
Contributor

Thanks for reporting, @emados. It does sound like a bug that we can fix.

If you need a workaround in the meantime, and you have a single static index.html file, you can probably get away with adding this to your build configuration:

{
  templatedUrls: {
    '/': ['index.html']
  },
  // ...other build config options as before...
}

That will explicitly create a cache entry for / which corresponds to the contents of index.html.

@jeffposnick jeffposnick self-assigned this Aug 21, 2017
@jeffposnick jeffposnick added Bug An issue with our existing, production codebase. and removed Discuss An open question, where input from the community would be appreciated. question labels Aug 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An issue with our existing, production codebase.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants