Skip to content
Myr

Added chars param to 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 24bca5d · Browse files · 3 files+14 added−6 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+14 added−6 removed

  • tests:+6 added−2 removed
  • other:+8 added−4 removed

3 files+14 added−6 removed

modified:lib/express.core.js+8 added-4 removed
156 unmodified lines
157 return path.replace(/^(\s|\/)*|(\s|\/)*$/g, '')158 },159 160 pathToRegexp : function(path) {161 return path.constructor == RegExp ? path :162 new RegExp('^' + path + '$')161 if (path.constructor == RegExp) return path162 path = path.replace(/:(\w+)/, function(key){163 (Express.regexpKeys = Express.regexpKeys || []).push(key)164 return '(.*?)'165 })166 return new RegExp('^' + this.escapeRegexp(path, '/ [ ]') + '$')167 },168 165 escapeRegexp : function(string) {166 var specials = '/ . * + ? | ( ) [ ] { } \\'.split(' ').join('|\\')169 escapeRegexp : function(string, chars) {170 var specials = (chars || '/ . * + ? | ( ) [ ] { } \\').split(' ').join('|\\')171 return string.replace(new RegExp('(\\' + specials + ')', 'g'), '\\$1')172 },173 174 /**
137 unmodified lines
modified:spec/spec.core.js+4 added
modified:spec/spec.routing.js+2 added-2 removed