From 226c88c9da81f2952646e37c3689525e15e55538 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 22 Dec 2017 20:45:13 -0800 Subject: [PATCH] Adding some additional console logging to the service worker. --- src/fetcher.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fetcher.js b/src/fetcher.js index 32d35f7..012ad0f 100644 --- a/src/fetcher.js +++ b/src/fetcher.js @@ -76,6 +76,7 @@ self.addEventListener('fetch', (event) => { }).then((files) => { // If there's just one result, return it. if (files.length == 1 && files[0].content) { + console.log('found file content at', files[0].path) return response(200, 'OK', files[0].content) } @@ -83,16 +84,19 @@ self.addEventListener('fetch', (event) => { // doesn't have a trailing slash, redirect. This ensures relative paths work correctly // for any resources pulled in on the page. if (files.length > 1 && event.request.url.slice(-1) != '/') { + console.log('redirect to', event.request.url + '/') return response(302, 'Found', '', {'Location': event.request.url + '/'}) } // If there are multiple results, look for an index.html page to return. for (let file of files) { if (file.path.endsWith('/index.html')) { + console.log('found file content at', file.path) return response(200, 'OK', file.content) } } + console.log('file not found at', event.request.url) return response( 404, 'Not Found', Buffer.from('404 Not Found

404 Not Found


Intergalactic
'),