Skip to content
Myr

Merge pull request #1868 from dpatti/smarter-router-auto-options

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

Automatic OPTIONS response breaks with multiple routers

authored by Roman Shtylman · committed by Roman Shtylman · parents ac2cbef, a3b5f6d · Browse files · 2 files+27 added−2 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+27 added−2 removed

  • tests:+24 added−0 removed
  • other:+3 added−2 removed

2 files+27 added−2 removed

modified:lib/router/index.js+3 added-2 removed
102 unmodified lines
103 // match route104 req.route = route = self.matchRequest(req, i);105106 // implied OPTIONS107 if (!route && 'OPTIONS' == req.method) return self._options(req, res);107 if (!route && 'OPTIONS' == req.method) return self._options(req, res, next);108109 // no route110 if (!route) return next(err);111 debug('matched %s %s', route.method, route.path);
68 unmodified lines
180 * @param {ServerResponse} res181 * @api private182 */183184Router.prototype._options = function(req, res){184Router.prototype._options = function(req, res, next){185 var path = parse(req).pathname186 , body = this._optionsFor(path).join(',');187 if (!body) return next();188 res.set('Allow', body).send(body);189};190191/**
130 unmodified lines
modified:test/app.options.js+24 added