summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/template.js4
-rw-r--r--lib/utils/string.js5
-rw-r--r--package.json3
3 files changed, 4 insertions, 8 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)
diff --git a/package.json b/package.json
index b6303e6..b9c1305 100644
--- a/package.json
+++ b/package.json
@@ -32,7 +32,8 @@
"npm": "2.4.1",
"dom-serializer": "0.1.0",
"spawn-cmd": "0.0.2",
- "highlight.js": "8.4.0"
+ "highlight.js": "8.4.0",
+ "escape-string-regexp": "1.0.3"
},
"devDependencies": {
"mocha": "2.2.1",