Skip to content
Myr

Issue 944:

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

Changing Router#match() signature from (req[, i]) to (method, url[, i]), and making it public

authored by riadhchtara · committed by riadhchtara · parent 136f054 · Browse files · 2 files+51 added−8 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+51 added−8 removed

  • tests:+30 added−5 removed
  • other:+21 added−3 removed

2 files+51 added−8 removed

modified:lib/router/index.js+21 added-3 removed
101 unmodified lines
102 pass(req._route_index + 1, err);103 }104105 // match route106 req.route = route = self.match(req, i);106 req.route = route = self.matchReq(req, i);107108 // implied OPTIONS109 if (!route && 'OPTIONS' == req.method) return self._options(req, res);110
108 unmodified lines
219 * @return {Route}220 * @api private221 */222223Router.prototype.match = function(req, i, head){223Router.prototype.matchReq = function(req, i, head){224 var method = req.method.toLowerCase()225 , url = parse(req)226 , path = url.pathname227 , routes = this.map
1 unmodified line
229 , route;230231 // HEAD support232 if (!head && 'head' == method) {233 route = this.match(req, i, true);233 route = this.matchReq(req, i, true);234 if (route) return route;235 method = 'get';236 }237
11 unmodified lines
249 }250};251252/**253 * Attempt to match a route for `method`254 * and `url` with optional starting255 * index of `i` defaulting to 0.256 *257 * @param {String} method258 * @param {String} url259 * @param {Number} i260 * @return {Route}261 * @api public262 */263264Router.prototype.match = function(method, url, i, head){265 method = method.toLowerCase(); 266 var req = { method: method, url: url };267 return this.matchReq(req, i, head);268};269270/**271 * Route `method`, `path`, and one or more callbacks.272 *273 * @param {String} method274 * @param {String} path
23 unmodified lines
modified:test/Router.js+30 added-5 removed