@@ -142,9 +142,9 @@ async function _fetch(e) {
142142 }
143143
144144 if ( url . pathname . endsWith ( "/" ) ) {
145- return e . respondWith ( redirectOr404 ( appendURL ( url , 'index.html' ) . pathname ) ) ;
146- } else if ( url . pathname . indexOf ( "." ) < 0 ) {
147- return e . respondWith ( redirectOr404 ( appendURL ( url , '/index.html' ) . pathname ) ) ;
145+ return e . respondWith ( redirectToUrl ( appendURL ( url , 'index.html' ) . pathname , request ) ) ;
146+ } else if ( url . pathname . indexOf ( "." ) < 0 || url . pathname . endsWith ( "/boot" ) ) {
147+ return e . respondWith ( redirectToUrl ( appendURL ( url , '/index.html' ) . pathname , request ) ) ;
148148 } else {
149149 e . respondWith ( fromCacheOrNetwork ( request ) ) ;
150150 }
@@ -155,16 +155,9 @@ function appendURL(url, append) {
155155 return new URL ( url . origin + url . pathname + append + url . search ) ;
156156}
157157
158- async function redirectOr404 ( path ) {
159- const cache = await cacheOpen ;
160- const hit = await cache . match ( path , { ignoreSearch : true } ) ;
161- if ( hit ) {
162- if ( debug ) log ( 'REDIRECT' , path ) ;
163- return Response . redirect ( path , 302 ) ;
164- } else {
165- if ( debug ) log ( '404' , path ) ;
166- return new Response ( 'Not Found' , { status : 404 , statusText : 'Not Found' } ) ;
167- }
158+ async function redirectToUrl ( path , request ) {
159+ if ( debug ) log ( 'REDIRECT' , path ) ;
160+ return Response . redirect ( path , 302 ) ;
168161}
169162
170163async function fromCacheOrNetwork ( req ) {
0 commit comments