Skip to content
Myr

Added escapeRegexp()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent 9128dc1 · Browse files · 3 files+24 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+24 added−1 removed

  • tests:+14 added−1 removed
  • other:+10 added−0 removed

3 files+24 added−1 removed

modified:lib/express.core.js+10 added
155 unmodified lines
156 normalizePath : function(path) {157 return path.replace(/^(\s|\/)*|(\s|\/)*$/g, '')158 },159 160 pathToRegexp : function(path) {161 return path.constructor == RegExp ? path :162 new RegExp('^' + path + '$')163 },164 165 escapeRegexp : function(string) {166 var specials = '/ . * + ? | ( ) [ ] { } \\'.split(' ').join('|\\')167 return string.replace(new RegExp('(\\' + specials + ')', 'g'), '\\$1')168 },169 170 /**171 * Return the contents of a function body.172 *173 * @param {function} body
134 unmodified lines
modified:spec/spec.core.js+6 added
modified:spec/spec.routing.js+8 added-1 removed