diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/template.js | 4 | ||||
-rw-r--r-- | lib/utils/string.js | 5 |
2 files changed, 2 insertions, 7 deletions
diff --git a/lib/template.js b/lib/template.js index 187df87..3e6364d 100644 --- a/lib/template.js +++ b/lib/template.js @@ -2,9 +2,9 @@ var _ = require("lodash"); var Q = require("q"); var path = require("path"); var nunjucks = require("nunjucks"); +var escapeStringRegexp = require("escape-string-regexp"); var git = require("./utils/git"); -var stringUtils = require("./utils/string"); var fs = require("./utils/fs"); var batch = require("./utils/batch"); var pkg = require("../package.json"); @@ -302,7 +302,7 @@ TemplateEngine.prototype.addBlock = function(name, block) { TemplateEngine.prototype._applyShortcut = function(parser, content, shortcut) { if (!_.contains(shortcut.parsers, parser)) return content; var regex = new RegExp( - stringUtils.escapeRegex(shortcut.start) + "([\\s\\S]*?[^\\$])" + stringUtils.escapeRegex(shortcut.end), + escapeStringRegexp(shortcut.start) + "([\\s\\S]*?[^\\$])" + escapeStringRegexp(shortcut.end), 'g' ); return content.replace(regex, function(all, match) { diff --git a/lib/utils/string.js b/lib/utils/string.js index 588f4d9..72a9ca0 100644 --- a/lib/utils/string.js +++ b/lib/utils/string.js @@ -20,12 +20,7 @@ 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) |