fix(patches): correct template literal escaping in livefetch patch

The nested template literal in the patch output had over-escaped regex
and backticks (\\\\/ instead of \\/, \\\` instead of \`), producing
invalid JS that caused a SyntaxError at runtime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sven
2026-03-18 17:41:47 +01:00
parent 1f4f55d4fc
commit 9662db1ec3
@@ -81,11 +81,11 @@ const newBlock = ` // [patched:livefetch] Always fetch the live page so t
let contentToProcess = ""; let contentToProcess = "";
try { try {
const _wmInternalBase = (() => { const _wmInternalBase = (() => {
if (process.env.INTERNAL_FETCH_URL) return process.env.INTERNAL_FETCH_URL.replace(/\\\\/+$/, ""); if (process.env.INTERNAL_FETCH_URL) return process.env.INTERNAL_FETCH_URL.replace(/\\/+$/, "");
const port = process.env.PORT || "3000"; const port = process.env.PORT || "3000";
return \\\`http://localhost:\\\${port}\\\`; return \`http://localhost:\${port}\`;
})(); })();
const _wmPublicBase = (process.env.PUBLICATION_URL || process.env.SITE_URL || "").replace(/\\\\/+$/, ""); const _wmPublicBase = (process.env.PUBLICATION_URL || process.env.SITE_URL || "").replace(/\\/+$/, "");
const fetchUrl = (_wmPublicBase && postUrl.startsWith(_wmPublicBase)) const fetchUrl = (_wmPublicBase && postUrl.startsWith(_wmPublicBase))
? _wmInternalBase + postUrl.slice(_wmPublicBase.length) ? _wmInternalBase + postUrl.slice(_wmPublicBase.length)
: postUrl; : postUrl;