diff --git a/main.js b/main.js index 22c09ef5..29e6b854 100644 --- a/main.js +++ b/main.js @@ -8,15 +8,15 @@ const { const path = require('path'); // This is used to set capabilities of the app: protocol in onready event below -protocol.registerSchemesAsPrivileged([{ - scheme: 'app', - privileges: { - standard: true, - secure: true, - allowServiceWorkers: true, - supportFetchAPI: true - } -}]); +// protocol.registerSchemesAsPrivileged([{ +// scheme: 'app', +// privileges: { +// standard: true, +// secure: true, +// allowServiceWorkers: true, +// supportFetchAPI: true +// } +// }]); // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. @@ -45,6 +45,7 @@ function createWindow() { // and load the index.html of the app. // mainWindow.loadURL(`https://${__dirname}/www/index.html`); + // mainWindow.loadURL(`https://kiwix.github.io/kiwix-js-windows/`); // DEV: If you need Service Worker more than you need document.cookie, load app like this: mainWindow.loadFile('www/index.html'); diff --git a/pwabuilder-sw.js b/pwabuilder-sw.js index 4cad7ea4..171e222e 100644 --- a/pwabuilder-sw.js +++ b/pwabuilder-sw.js @@ -135,7 +135,7 @@ self.addEventListener('fetch', intercept); // Look up fetch in cache, and if it does not exist, try to get it from the network function intercept(event) { - if (excludedURLSchema.test(event.request.url) && !(/\.zim\w{0,2}\//i.test(event.request.url) || regexpZIMUrlWithNamespace.test(event.request.url))) return; + if (excludedURLSchema.test(event.request.url) && !(/\.zim\w{0,2}\//i.test(event.request.url) && regexpZIMUrlWithNamespace.test(event.request.url))) return; console.log('[SW] Service Worker ' + (event.request.method === "GET" ? 'intercepted ' : 'noted ') + event.request.url, event.request.method); if (event.request.method !== "GET") return; event.respondWith( diff --git a/www/js/app.js b/www/js/app.js index 91d38e98..50026e4c 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -2112,7 +2112,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki // For Electron, we need to set an absolute filepath in case the file was launched from a shortcut (and if it's not already absolute) // DEV: Periodically check Electron hasn't changed its resources folder; NB the ! in indexOf below indicates position at start of string if (!filepath.indexOf(params.archivePath) && /^file:/.test(window.location.protocol)) { - filepath = window.location.pathname.replace(/^\//, '').replace(/resources\/app\/www\/[^/]+$/, '') + filepath; + filepath = window.location.pathname.replace(/^\//, '').replace(/(resources\/app\/)?www\/[^/]+$/, '') + filepath; } file.name = filename; file.path = filepath;