fix paths to host app in non-root side folder

This commit is contained in:
Dmitry Vasilev
2023-01-18 16:30:44 +08:00
parent 9a6b700086
commit 25044547d6
3 changed files with 8 additions and 7 deletions

View File

@@ -30,12 +30,12 @@ self.addEventListener('message', async function(e) {
})
// Fake directory, http requests to this directory intercepted by service_worker
const FILES_ROOT = '__leporello_files'
const FILES_ROOT = new URL('.', globalThis.location).pathname + '__leporello_files/'
self.addEventListener("fetch", event => {
const url = new URL(event.request.url)
if(url.pathname.startsWith('/' + FILES_ROOT)) {
const path = url.pathname.replace('/' + FILES_ROOT + '/', '')
if(url.pathname.startsWith(FILES_ROOT)) {
const path = url.pathname.replace(FILES_ROOT, '')
let file