Skip to content

Commit b1157be

Browse files
committed
fix serviceworker discovery
Signed-off-by: Matthias Wippich <mfwippich@gmail.com>
1 parent f8ad903 commit b1157be

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

public/codeblocks.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@
4747
"Service workers are unavailable; clangd cannot enable cross-origin isolation",
4848
);
4949
} else {
50-
var workerUrl = new URL(
51-
serviceWorker || "./coi-serviceworker.js",
52-
script.src,
53-
);
50+
// An explicitly configured worker belongs to the host page, so its
51+
// relative URL follows normal HTML attribute semantics. The bundled
52+
// fallback remains relative to this loader script.
53+
var workerUrl = serviceWorker
54+
? new URL(serviceWorker, document.baseURI)
55+
: new URL("./coi-serviceworker.js", script.src);
5456
log("Registering isolation service worker at " + workerUrl.href);
5557
await navigator.serviceWorker.register(workerUrl, { scope: "./" });
5658
await navigator.serviceWorker.ready;

0 commit comments

Comments
 (0)