mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
service-worker: don't serve index.html for static
This fixes issues where the index.html page can be served if we have something that requests a static resource that does not exist. In the worst case, this would the app appear recursively in the docs pane. Also remove some unnecessary typing while we are touching this.
This commit is contained in:
committed by
David Lechner
parent
6dc03ad911
commit
74d8a258fb
@@ -34,12 +34,17 @@ precacheAndRoute(self.__WB_MANIFEST, { ignoreURLParametersMatching: [/.*/] });
|
||||
const fileExtensionRegexp = new RegExp('/[^/?]+\\.[^/]+$');
|
||||
registerRoute(
|
||||
// Return false to exempt requests from being fulfilled by index.html.
|
||||
({ request, url }: { request: Request; url: URL }) => {
|
||||
({ request, url }) => {
|
||||
// If this isn't a navigation, skip.
|
||||
if (request.mode !== 'navigate') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If this is a URL for a static resource, skip.
|
||||
if (url.pathname.startsWith('/static/')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If this is a URL that starts with /_, skip.
|
||||
if (url.pathname.startsWith('/_')) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user