Skip to content
Myr

Merge pull request #1212 from riadhchtara/Issue944

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

issue#944 : Changing Router#match() signature

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parents 4f7c4d1, 8ccd89f · Browse files · 2 files+51 added−9 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−9 removed

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

2 files+51 added−9 removed

modified:lib/router/index.js+21 added-4 removed
11/**2 * Module dependencies.3 */4
96 unmodified lines
101 pass(req._route_index + 1, err);102 }103104 // match route106 req.route = route = self.match(req, i);105 req.route = route = self.matchReq(req, i);106107 // implied OPTIONS108 if (!route && 'OPTIONS' == req.method) return self._options(req, res);109
108 unmodified lines
218 * @return {Route}219 * @api private220 */221223Router.prototype.match = function(req, i, head){222Router.prototype.matchReq = function(req, i, head){223 var method = req.method.toLowerCase()224 , url = parse(req)225 , path = url.pathname226 , routes = this.map
1 unmodified line
228 , route;229230 // HEAD support231 if (!head && 'head' == method) {233 route = this.match(req, i, true);232 route = this.matchReq(req, i, true);233 if (route) return route;234 method = 'get';235 }236
11 unmodified lines
248 }249};250251/**252 * Attempt to match a route for `method`253 * and `url` with optional starting254 * index of `i` defaulting to 0.255 *256 * @param {String} method257 * @param {String} url258 * @param {Number} i259 * @return {Route}260 * @api private261 */262263Router.prototype.match = function(method, url, i, head){264 method = method.toLowerCase(); 265 var req = { method: method, url: url };266 return this.matchReq(req, i, head);267};268269/**270 * Route `method`, `path`, and one or more callbacks.271 *272 * @param {String} method273 * @param {String} path
23 unmodified lines
modified:test/Router.js+30 added-5 removed