diff --git a/lib/utils/common.js b/lib/utils/common.js index 7cb9d70..a04cbe7 100644 --- a/lib/utils/common.js +++ b/lib/utils/common.js @@ -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 * https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem