Skip to content
Myr

router: moved params logic to Router#match()

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

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 6d323d3 · Browse files · 2 files+26 added−24 removed
This commit

State

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

Diff stats

2 files+26 added−24 removed

  • other:+26 added−24 removed

2 files+26 added−24 removed

modified:lib/router/index.js+2 added-21 removed
235 unmodified lines
236 , url = parse(req.url)237 , path = url.pathname238 , routes = this.map239 , i = i || 0240 , captures241 , route240 , route;242 , keys;241242 // HEAD support243 // TODO: clean this up244 if (!head && 'head' == method) {
11 unmodified lines
256257 // matching routes258 for (var len = routes.length; i < len; ++i) {259 route = routes[i];262 if (captures = route.match(path)) {263 keys = route.keys;264 route.params = [];265266 // params from capture groups267 for (var j = 1, jlen = captures.length; j < jlen; ++j) {268 var key = keys[j-1]269 , val = 'string' == typeof captures[j]270 ? decodeURIComponent(captures[j])271 : captures[j];272 if (key) {273 route.params[key.name] = val;274 } else {275 route.params.push(val);276 }277 }278279 // all done260 if (route.match(path)) {261 req._route_index = i;262 return route;263 }264 }
31 unmodified lines
modified:lib/router/route.js+24 added-3 removed