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

pwa can't cache resource with space in url #25443

Open
zh99998 opened this issue Aug 12, 2018 · 2 comments
Open

pwa can't cache resource with space in url #25443

zh99998 opened this issue Aug 12, 2018 · 2 comments
Labels
area: service-worker Issues related to the @angular/service-worker package effort1: hours freq1: low P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent state: confirmed type: bug/fix
Milestone

Comments

@zh99998
Copy link

zh99998 commented Aug 12, 2018

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

when where is a resources in assets directory, and filename includes space " ", the @angular/pwa service worker can't cache it correctly.

Expected behavior

Minimal reproduction of the problem with instructions

ng add @angular/pwa
put an image named "a b.jpg" in assets
reference it in html
ng build --prod

open it in browser
enable offline mode in chrome devtools
refresh page
it will got a 504.

What is the motivation / use case for changing the behavior?

Environment


Angular version: X.Y.Z


Browser:
- [x] Chrome (desktop) version 68
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@ngbot ngbot bot added this to the needsTriage milestone Aug 13, 2018
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Aug 13, 2018
@gkalpak
Copy link
Member

gkalpak commented Aug 13, 2018

This is a valid issue. The problem is that in the config generator, we process the file paths as reported by the filesystem, but the URL can differ (due to URI encoding).

So, the generated ngsw.json has an entry for /assets/a b.png, but the SW tries to match it with a request for /assets/a%20b.png and fails.

@jelbourn jelbourn added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed severity3: broken labels Oct 1, 2020
@Ruud-cb
Copy link

Ruud-cb commented Oct 28, 2020

Just a shoutout that this is still a problem.
Our team fixed it by using this in package.json:
"build:prod": "ng build --prod && npm run fix-ngsw",
"fix-ngsw": "shx sed -i \"([\\w\\)])( )([\\w\\(])\" '$1%20$3' dist/**/ngsw.json"

Using this and this dependency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: service-worker Issues related to the @angular/service-worker package effort1: hours freq1: low P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent state: confirmed type: bug/fix
Projects
None yet
Development

No branches or pull requests

6 participants