Skip to content

Commit

Permalink
fix: use split/join instead of replaceAll
Browse files Browse the repository at this point in the history
Support Node 14
  • Loading branch information
azu committed May 28, 2022
1 parent d85ae73 commit 9da4156
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/hook-inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SandboxOptions } from "./sandpack";
const escapeHTMLComment = (content: string) => {
// It will be restored when parsing comment
// to avoid break -->
return content.replaceAll("<!--", "\\u003c\\u0021\\u002d\\u002d").replaceAll("-->", "\\u002d\\u002d\\u003e");
return content.split("<!--").join("\\u003c\\u0021\\u002d\\u002d").split("-->").join("\\u002d\\u002d\\u003e");
};
export const inlineFiles = (content: string, filePath: string) => {
const baseDir = path.dirname(filePath);
Expand Down
6 changes: 4 additions & 2 deletions src/parse-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ Actual: ${comment}
try {
const json = JSON.parse(
optionString[1]
.replaceAll("\\\\u003c\\\\u0021\\\\u002d\\\\u002d", "<!--")
.replaceAll("\\\\u002d\\\\u002d\\\\u003e", "-->")
.split("\\\\u003c\\\\u0021\\\\u002d\\\\u002d")
.join("<!--")
.split("\\\\u002d\\\\u002d\\\\u003e")
.join("-->")
);
return {
...json
Expand Down

0 comments on commit 9da4156

Please sign in to comment.