-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix(service-worker): change routing to allow redirect to login page #669
Conversation
// a file extension, skip (unless it's index.html) | ||
if ( | ||
fileExtensionRegexp.test(url.pathname) && | ||
!/index\.html$/.test(url.pathname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The (relatively) new String.prototype.endsWith
would allow making the intention of this line a bit clearer:
!/index\.html$/.test(url.pathname) | |
!url.pathname.endsWith("index.html") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that 🙂
// Extract index.html from the manifest to precache, then route | ||
// in a custom way | ||
const indexHtmlManifestEntry = precacheManifest.find(({ url }) => | ||
url.includes('index.html') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be url.endsWith('index.html')
too since this would match e.g. index.html.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah yeah, fair point 🙂
## [8.1.2](v8.1.1...v8.1.2) (2021-10-04) ### Bug Fixes * **service-worker:** change routing to allow redirect to login page ([#669](#669)) ([97c84d4](97c84d4))
🎉 This PR is included in version 8.1.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Addresses https://jira.dhis2.org/browse/LIBS-238
Can be tested like this:
pwa
package,adapter
package, then the pwa-app/api/apps/pwa-app/
and/api/apps/pwa-app/index.html
; verify app loads/api/apps/pwa-app/hi
and verify app loads (tests that subroutes are handled by index.html)/api/apps/pwa-app//manifest.json
to make sure you can visit static files