parent
e71014f522
commit
24d1c98c0a
@ -1,6 +1,7 @@
|
||||
unreleased
|
||||
==========
|
||||
|
||||
* Fix `res.format` error when only `default` provided
|
||||
* Fix issue where `next('route')` in `app.param` would incorrectly skip values
|
||||
* Use `array-flatten` module for flattening arrays
|
||||
* deps: accepts@~1.2.9
|
||||
|
@ -606,7 +606,9 @@ res.format = function(obj){
|
||||
if (fn) delete obj.default;
|
||||
var keys = Object.keys(obj);
|
||||
|
||||
var key = req.accepts(keys);
|
||||
var key = keys.length > 0
|
||||
? req.accepts(keys)
|
||||
: false;
|
||||
|
||||
this.vary("Accept");
|
||||
|
||||
|
@ -67,6 +67,14 @@ app4.use(function(err, req, res, next){
|
||||
res.send(err.status, 'Supports: ' + err.types.join(', '));
|
||||
})
|
||||
|
||||
var app5 = express();
|
||||
|
||||
app5.use(function (req, res, next) {
|
||||
res.format({
|
||||
default: function () { res.send('hey') }
|
||||
});
|
||||
});
|
||||
|
||||
describe('res', function(){
|
||||
describe('.format(obj)', function(){
|
||||
describe('with canonicalized mime types', function(){
|
||||
@ -102,6 +110,13 @@ describe('res', function(){
|
||||
.set('Accept', 'text/html')
|
||||
.expect('default', done);
|
||||
})
|
||||
|
||||
it('should work when only .default is provided', function (done) {
|
||||
request(app5)
|
||||
.get('/')
|
||||
.set('Accept', '*/*')
|
||||
.expect('hey', done);
|
||||
})
|
||||
})
|
||||
|
||||
describe('in router', function(){
|
||||
|
Loading…
Reference in New Issue
Block a user