diff --git a/src/pac_utils_dump.c b/src/pac_utils_dump.c index cf748af..83217b7 100644 --- a/src/pac_utils_dump.c +++ b/src/pac_utils_dump.c @@ -16,7 +16,9 @@ int main() { printf("// directly, so that the eval'd PAC sandbox can define its own\n"); printf("// dnsResolve() / myIpAddress() in the same scope as the utility\n"); printf("// functions — keeping DNS mocking correct via lexical scoping.\n"); - printf("const PAC_UTILS_JS = `\n"); + // String.raw preserves backslashes as-is, preventing the JS template + // literal parser from mangling regex patterns like /\*/g → /*/g (invalid). + printf("const PAC_UTILS_JS = String.raw`\n"); printf("%s", pacUtils); printf("`;\n"); return 0; diff --git a/web/pac_utils.js b/web/pac_utils.js index a90864e..b87826b 100644 --- a/web/pac_utils.js +++ b/web/pac_utils.js @@ -5,7 +5,7 @@ // directly, so that the eval'd PAC sandbox can define its own // dnsResolve() / myIpAddress() in the same scope as the utility // functions — keeping DNS mocking correct via lexical scoping. -const PAC_UTILS_JS = ` +const PAC_UTILS_JS = String.raw` function dnsDomainIs(host, domain) { return (host.length >= domain.length && host.substring(host.length - domain.length) == domain);