Skip to content

Commit

Permalink
Fix escape strategy for newer versions of metro
Browse files Browse the repository at this point in the history
  • Loading branch information
edjiang committed Sep 22, 2023
1 parent 2ce32d2 commit e4a90e1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/plugin/html.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ROOT_ID } from "../common";

const escape = (src) => src.replace(/`/g, "\\`");

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

const wrapByHtml = (js) => `
<!DOCTYPE html>
Expand Down

0 comments on commit e4a90e1

Please sign in to comment.