Skip to content
Myr

Fixed default OPTIONS behavior

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 5e56446 · Browse files · 2 files+23 added−1 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+23 added−1 removed

  • tests:+22 added−0 removed
  • other:+1 added−1 removed

2 files+23 added−1 removed

modified:lib/router/index.js+1 added-1 removed
309 unmodified lines
310311Router.prototype._optionsFor = function(path){312 var self = this;313 return methods.filter(function(method){314 var routes = self.routes[method];314 var routes = self.map[method];315 if (!routes || 'options' == method) return;316 for (var i = 0, len = routes.length; i < len; ++i) {317 if (routes[i].match(path)) return true;318 }
86 unmodified lines
modified:test/app.router.js+22 added
18 unmodified lines
19 })20 });21 })2223 describe('OPTIONS', function(){24 it('should default to the routes defined', function(done){25 var app = express();2627 app.get('/users', function(req, res){28 29 });3031 app.put('/users', function(req, res){32 33 });3435 request(app)36 .options('/users')37 .end(function(res){38 res.body.should.equal('GET,PUT');39 res.headers.should.have.property('allow', 'GET,PUT');40 done();41 });42 })43 })4445 it('should be .use()able', function(done){46 var app = express();4748 var calls = [];
409 unmodified lines