Skip to content

Commit

Permalink
Merge pull request #133 from edjiang/main
Browse files Browse the repository at this point in the history
Fix escape strategy for newer versions of metro
  • Loading branch information
inokawa authored Sep 23, 2023
2 parents 2ce32d2 + e4a90e1 commit 03cf293
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 03cf293

Please sign in to comment.