Skip to content
Myr

Fixed route placeholder segment capture issue [#48]

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

authored by visionmedia · committed by visionmedia · parent 04c0645 · Browse files · 1 file+5 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

1 file+5 added−6 removed

  • other:+5 added−6 removed

1 file+5 added−6 removed

modified:lib/express/core.js+5 added-6 removed
72 unmodified lines
73 * Normalize _path_. When a RegExp it is simply returned,74 * otherwise a string is converted to a regular expression75 * surrounded by ^$. So /user/:id/edit would become:76 *77 * \^/user/(.*?)\/edit\$/77 * /^\/user\/([^\/]+)\/edit$/i78 *79 * Each param key (:id) will be captured and placed in the80 * params array, so param('id') would give the string captured.81 *
11 unmodified lines
93 normalize: function(path) {94 var self = this95 this.keys = []96 if (path instanceof RegExp) return path97 return new RegExp('^' + 98 escapeRegexp(normalizePath(path)97 return new RegExp('^' + normalizePath(path)98 .replace(/\/:(\w+)\?/g, function(_, key){99 self.keys.push(key)101 return '(?:\/(.*?))?'100 return '(?:\/([^\/]+))?'101 })102 .replace(/:(\w+)/g, function(_, key){103 self.keys.push(key)105 return '(.*?)'106 }), '/ [ ]') + '$', 'i')104 return '([^\/]+)'105 }) + '$', 'i')106 }107})108109// --- Router
177 unmodified lines