Skip to content

Commit 03cf293

Browse files
authored
Merge pull request #133 from edjiang/main
Fix escape strategy for newer versions of metro
2 parents 2ce32d2 + e4a90e1 commit 03cf293

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/plugin/html.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ROOT_ID } from "../common";
22

3-
const escape = (src) => src.replace(/`/g, "\\`");
4-
5-
export const createContent = (js) =>
6-
`export default String.raw\`${escape(wrapByHtml(js))}\`;`;
3+
export const createContent = (js) => {
4+
js = js.replace(/([`$])/g, '\\$1');
5+
return "export default String.raw`\n"+wrapByHtml(js)+"\n`.replace(/\\\\([`$])/g, '\\$1')";
6+
}
77

88
const wrapByHtml = (js) => `
99
<!DOCTYPE html>

0 commit comments

Comments
 (0)