Skip to content

Commit 9da4156

Browse files
committed
fix: use split/join instead of replaceAll
Support Node 14
1 parent d85ae73 commit 9da4156

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/hook-inline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { SandboxOptions } from "./sandpack";
66
const escapeHTMLComment = (content: string) => {
77
// It will be restored when parsing comment
88
// to avoid break -->
9-
return content.replaceAll("<!--", "\\u003c\\u0021\\u002d\\u002d").replaceAll("-->", "\\u002d\\u002d\\u003e");
9+
return content.split("<!--").join("\\u003c\\u0021\\u002d\\u002d").split("-->").join("\\u002d\\u002d\\u003e");
1010
};
1111
export const inlineFiles = (content: string, filePath: string) => {
1212
const baseDir = path.dirname(filePath);

src/parse-comment.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ Actual: ${comment}
1818
try {
1919
const json = JSON.parse(
2020
optionString[1]
21-
.replaceAll("\\\\u003c\\\\u0021\\\\u002d\\\\u002d", "<!--")
22-
.replaceAll("\\\\u002d\\\\u002d\\\\u003e", "-->")
21+
.split("\\\\u003c\\\\u0021\\\\u002d\\\\u002d")
22+
.join("<!--")
23+
.split("\\\\u002d\\\\u002d\\\\u003e")
24+
.join("-->")
2325
);
2426
return {
2527
...json

0 commit comments

Comments
 (0)