Fix string escape single qupte

This commit is contained in:
barsdeveloper
2023-04-03 20:02:58 +02:00
parent 62b3968af3
commit 2380d61bb6
5 changed files with 16 additions and 9 deletions

View File

@@ -299,8 +299,7 @@ export default class Utility {
/** @param {String} value */
static escapeString(value) {
return value
.replaceAll('\\', '\\\\') // Escape \
.replaceAll('"', '\\"') // Escape "
.replaceAll(new RegExp(`(${Configuration.stringEscapedCharacters.source})`, "g"), '\\$1')
.replaceAll("\n", "\\n") // Replace newline with \n
.replaceAll("\t", "\\t") // Replace tab with \t
}
@@ -310,8 +309,7 @@ export default class Utility {
return value
.replaceAll("\\t", "\t") // Replace tab with \t
.replaceAll("\\n", "\n") // Replace newline with \n
.replaceAll('\\"', '"') // Escape "
.replaceAll('\\\\', '\\') // Escape \
.replaceAll(new RegExp(`\\\\(${Configuration.stringEscapedCharacters.source})`, "g"), "$1")
}
/** @param {String} value */