Add unquote method
This commit is contained in:
parent
aaa01050e2
commit
ac7f4b3580
1 changed files with 13 additions and 0 deletions
|
@ -24,6 +24,19 @@ class common extends utils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove quotes and escape sequence from string
|
||||||
|
* @param {string} s
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
static unquote (s) {
|
||||||
|
return s.replace(/\\'/g, '\'')
|
||||||
|
.replace(/\\"/g, '"')
|
||||||
|
.replace(/\\0/g, '\0')
|
||||||
|
.replace(/\\\\/g, '\\')
|
||||||
|
.replace(/(^['|"])(.*)\1$/gm, '$2')
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unicode safe b64 encoding
|
* Unicode safe b64 encoding
|
||||||
* https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem
|
* https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem
|
||||||
|
|
Loading…
Reference in a new issue