Skip to content

Commit 59e21a4

Browse files
committed
fix(prefetchSW): correct script path replace
1 parent 788b871 commit 59e21a4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/qwik/src/core/components/prefetch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const PrefetchServiceWorker = (opts: {
4242
// the file 'qwik-prefetch-service-worker.js' is not located in /build/
4343
resolvedOpts.path = baseUrl + resolvedOpts.path;
4444
}
45-
let code = PREFETCH_CODE.replace('URL', resolvedOpts.path);
45+
let code = PREFETCH_CODE.replace("'_URL_'", JSON.stringify(resolvedOpts.path));
4646
if (!isDev) {
4747
// consecutive spaces are indentation
4848
code = code.replaceAll(/\s\s+/gm, '');
@@ -67,7 +67,7 @@ const PREFETCH_CODE = /*#__PURE__*/ ((
6767
c.getRegistrations().then((registrations) => {
6868
registrations.forEach((registration) => {
6969
if (registration.active) {
70-
if (registration.active.scriptURL.endsWith('URL')) {
70+
if (registration.active.scriptURL.endsWith('_URL_')) {
7171
registration.unregister().catch(console.error);
7272
}
7373
}

0 commit comments

Comments
 (0)