Skip to content

Commit 0620f88

Browse files
committed
Fix the use of replace vs. replaceAll in the JS side parser AST objects. Thus allowing the use of those AST classes to escape "strings" correctly, when generating code.
1 parent 08edeb2 commit 0620f88

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

corsscripts/stackmplite.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,12 @@ class MPString extends MPAtom {
298298
}
299299

300300
toString(opt) {
301-
return '"' + this.value.replace("\\", "\\\\").replace('"', "\\\"") + '"';
301+
return '"' + this.value.replaceAll("\\", "\\\\").replaceAll('"', "\\\"") + '"';
302302
}
303303

304304
translate(opt) {
305305
// We will use 'strings' to match JessieCode and JS at the same time.
306-
return "'" + this.value.replace("\\", "\\\\").replace("'", "\\'").replace("\n", "\\n").replace("\t", "\\t") + "'";
306+
return "'" + this.value.replaceAll("\\", "\\\\").replaceAll("'", "\\'").replaceAll("\n", "\\n").replaceAll("\t", "\\t") + "'";
307307
}
308308
}
309309

0 commit comments

Comments
 (0)