mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-13 08:34:46 +08:00
Fix string escape single qupte
This commit is contained in:
@@ -148,9 +148,18 @@ describe("Utility class", () => {
|
||||
expect(Utility.escapeString("")).to.be.equal("")
|
||||
expect(Utility.unescapeString("")).to.be.equal("")
|
||||
|
||||
expect(Utility.escapeString('"')).to.be.equal('\\"')
|
||||
expect(Utility.unescapeString('\\"')).to.be.equal('"')
|
||||
|
||||
expect(Utility.escapeString("'")).to.be.equal("\\'")
|
||||
expect(Utility.unescapeString("\\'")).to.be.equal("'")
|
||||
|
||||
expect(Utility.escapeString(String.raw`\"`)).to.be.equal(String.raw`\\\"`)
|
||||
expect(Utility.unescapeString(String.raw`\"`)).to.be.equal('"')
|
||||
|
||||
expect(Utility.escapeString(String.raw`\'`)).to.be.equal(String.raw`\\\'`)
|
||||
expect(Utility.unescapeString(String.raw`\'`)).to.be.equal("'")
|
||||
|
||||
expect(Utility.escapeString(String.raw`Hello \"World\"`)).to.be.equal(String.raw`Hello \\\"World\\\"`)
|
||||
expect(Utility.unescapeString(String.raw`Hello \"World\"`)).to.be.equal('Hello "World"')
|
||||
|
||||
|
||||
7
dist/ueblueprint.js
vendored
7
dist/ueblueprint.js
vendored
@@ -193,6 +193,7 @@ class Configuration {
|
||||
}
|
||||
static selectAllKeyboardKey = "(bCtrl=True,Key=A)"
|
||||
static smoothScrollTime = 1000 // ms
|
||||
static stringEscapedCharacters = /['"\\]/g
|
||||
static trackingMouseEventName = {
|
||||
begin: "ueb-tracking-mouse-begin",
|
||||
end: "ueb-tracking-mouse-end",
|
||||
@@ -740,8 +741,7 @@ 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
|
||||
}
|
||||
@@ -751,8 +751,7 @@ 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 */
|
||||
|
||||
2
dist/ueblueprint.min.js
vendored
2
dist/ueblueprint.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -169,6 +169,7 @@ export default class Configuration {
|
||||
}
|
||||
static selectAllKeyboardKey = "(bCtrl=True,Key=A)"
|
||||
static smoothScrollTime = 1000 // ms
|
||||
static stringEscapedCharacters = /['"\\]/g
|
||||
static trackingMouseEventName = {
|
||||
begin: "ueb-tracking-mouse-begin",
|
||||
end: "ueb-tracking-mouse-end",
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user