diff options
Diffstat (limited to 'lib/utils/string.js')
-rw-r--r-- | lib/utils/string.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/utils/string.js b/lib/utils/string.js index 72a9ca0..588f4d9 100644 --- a/lib/utils/string.js +++ b/lib/utils/string.js @@ -20,7 +20,12 @@ function optionsToShellArgs(options) { .join(" "); } +function escapeRegex(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); +} + module.exports = { + escapeRegex: escapeRegex, escapeShellArg: escapeShellArg, optionsToShellArgs: optionsToShellArgs, toLowerCase: String.prototype.toLowerCase.call.bind(String.prototype.toLowerCase) |