mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 00:19:48 +01:00
parent
fc4eb6dae0
commit
935f05bc84
|
|
@ -2,6 +2,7 @@ unreleased
|
|||
==========
|
||||
|
||||
* Deprecate leading `:` in `name` for `app.param(name, fn)`
|
||||
* Fix `OPTIONS` responses to include the `HEAD` method properly
|
||||
|
||||
4.10.8 / 2015-01-13
|
||||
===================
|
||||
|
|
|
|||
|
|
@ -52,10 +52,20 @@ Route.prototype._handles_method = function _handles_method(method) {
|
|||
* @api private
|
||||
*/
|
||||
|
||||
Route.prototype._options = function(){
|
||||
return Object.keys(this.methods).map(function(method) {
|
||||
return method.toUpperCase();
|
||||
});
|
||||
Route.prototype._options = function _options() {
|
||||
var methods = Object.keys(this.methods);
|
||||
|
||||
// append automatic head
|
||||
if (this.methods.get && !this.methods.head) {
|
||||
methods.push('head');
|
||||
}
|
||||
|
||||
for (var i = 0; i < methods.length; i++) {
|
||||
// make upper case
|
||||
methods[i] = methods[i].toUpperCase();
|
||||
}
|
||||
|
||||
return methods;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ describe('OPTIONS', function(){
|
|||
|
||||
request(app)
|
||||
.options('/users')
|
||||
.expect('GET,PUT')
|
||||
.expect('Allow', 'GET,PUT', done);
|
||||
.expect('Allow', 'GET,HEAD,PUT')
|
||||
.expect(200, 'GET,HEAD,PUT', done);
|
||||
})
|
||||
|
||||
it('should only include each method once', function(done){
|
||||
|
|
@ -26,8 +26,8 @@ describe('OPTIONS', function(){
|
|||
|
||||
request(app)
|
||||
.options('/users')
|
||||
.expect('GET,PUT')
|
||||
.expect('Allow', 'GET,PUT', done);
|
||||
.expect('Allow', 'GET,HEAD,PUT')
|
||||
.expect(200, 'GET,HEAD,PUT', done);
|
||||
})
|
||||
|
||||
it('should not be affected by app.all', function(done){
|
||||
|
|
@ -44,8 +44,8 @@ describe('OPTIONS', function(){
|
|||
request(app)
|
||||
.options('/users')
|
||||
.expect('x-hit', '1')
|
||||
.expect('allow', 'GET,PUT')
|
||||
.expect(200, 'GET,PUT', done);
|
||||
.expect('Allow', 'GET,HEAD,PUT')
|
||||
.expect(200, 'GET,HEAD,PUT', done);
|
||||
})
|
||||
|
||||
it('should not respond if the path is not defined', function(done){
|
||||
|
|
@ -68,8 +68,8 @@ describe('OPTIONS', function(){
|
|||
|
||||
request(app)
|
||||
.options('/other')
|
||||
.expect('GET')
|
||||
.expect('Allow', 'GET', done);
|
||||
.expect('Allow', 'GET,HEAD')
|
||||
.expect(200, 'GET,HEAD', done);
|
||||
})
|
||||
|
||||
describe('when error occurs in respone handler', function () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user