Comparing version 0.0.7 to 0.0.8
@@ -329,2 +329,10 @@ // Load modules | ||
// Escape string for Regex construction | ||
exports.escapeRegex = function (string) { | ||
// Escape ^$.*+?=!:|\/()[]{} | ||
return string.replace(/[\^\$\.\*\+\?\=\!\:\|\\\/\(\)\[\]\{\}]/g, '\\$&'); | ||
}; | ||
{ | ||
"name": "hoek", | ||
"description": "General purpose node utilities", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)", | ||
@@ -6,0 +6,0 @@ "contributors":[ |
@@ -94,2 +94,10 @@ var assert = require('assert'); | ||
}) | ||
describe("#escapeRegex", function () { | ||
it("should escape all special regular expression characters", function (done) { | ||
var a = hoek.escapeRegex('4^f$s.4*5+_?%=#!:@|~\\/`"(>)[<]d{}s,'); | ||
a.should.equal('4\\^f\\$s\\.4\\*5\\+_\\?%\\=#\\!\\:@\\|~\\\\\\/`"\\(>\\)\\[<\\]d\\{\\}s,'); | ||
done(); | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15076
323