From f25044253f2a7e8f21ddab767a95af08f5f1b505 Mon Sep 17 00:00:00 2001 From: ieow Date: Mon, 14 Oct 2024 12:00:18 +0800 Subject: [PATCH 1/2] feat: better escape strategy --- src/plugin/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin/index.ts b/src/plugin/index.ts index 93e56f2..eab639e 100644 --- a/src/plugin/index.ts +++ b/src/plugin/index.ts @@ -45,7 +45,7 @@ export const createTransformer = ( src: "export default String.raw`" + escape(res).replace(/\$\{(.*?)\}/g, "\\$\\{$1\\}") + - "`.replace(/\\\\([`${}])/g, '\\$1')", + "`.replace(/\\\\([`$])/g, '\\$1')", }); } From 6fe5de03a2136c9e668402c6f282732677c0d660 Mon Sep 17 00:00:00 2001 From: ieow Date: Mon, 14 Oct 2024 12:05:52 +0800 Subject: [PATCH 2/2] fix: *missing changes better escape --- src/plugin/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin/index.ts b/src/plugin/index.ts index eab639e..211fd67 100644 --- a/src/plugin/index.ts +++ b/src/plugin/index.ts @@ -44,7 +44,7 @@ export const createTransformer = ( ...args, src: "export default String.raw`" + - escape(res).replace(/\$\{(.*?)\}/g, "\\$\\{$1\\}") + + escape(res).replace(/\$/g, '\\$') + "`.replace(/\\\\([`$])/g, '\\$1')", }); }