sw.js: support calling /edit on a directory path
This commit is contained in:
parent
8bbbe96c22
commit
aaf4837aaa
|
@ -64,9 +64,13 @@ self.addEventListener('fetch', function(event) {
|
|||
}
|
||||
|
||||
if (pathname.endsWith("/edit")) {
|
||||
let offset_length = "/edit".length,
|
||||
let offset_length = "/edit".length - 1, // -1 to keep the trailing slash
|
||||
real_pathname = pathname.substring(0, pathname.length - offset_length);
|
||||
|
||||
if (real_pathname[real_pathname.length - 1] === "/") {
|
||||
real_pathname = real_pathname + "index.html";
|
||||
}
|
||||
|
||||
pathname = "/dev/";
|
||||
hash = "#action=edit&path=" + real_pathname;
|
||||
event.respondWith(Response.redirect(window.location.origin + pathname + hash));
|
||||
|
|
Loading…
Reference in New Issue