Skip to content
Myr

Fix res.format error when only default provided

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

fixes #2665

authored by Behcet Uyar · committed by Douglas Christopher Wilson · parent e71014f · Browse files · 3 files+19 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

3 files+19 added−1 removed

  • tests:+15 added−0 removed
  • other:+4 added−1 removed

3 files+19 added−1 removed

modified:lib/response.js+3 added-1 removed
604 unmodified lines
605 var fn = obj.default;606 if (fn) delete obj.default;607 var keys = Object.keys(obj);608609 var key = req.accepts(keys);609 var key = keys.length > 0610 ? req.accepts(keys)611 : false;612613 this.vary("Accept");614615 if (key) {
419 unmodified lines
modified:test/res.format.js+15 added
65 unmodified lines
66app4.use(function(err, req, res, next){67 res.send(err.status, 'Supports: ' + err.types.join(', '));68})6970var app5 = express();7172app5.use(function (req, res, next) {73 res.format({74 default: function () { res.send('hey') }75 });76});7778describe('res', function(){79 describe('.format(obj)', function(){80 describe('with canonicalized mime types', function(){81 test(app1);
27 unmodified lines
109 .get('/')110 .set('Accept', 'text/html')111 .expect('default', done);112 })113114 it('should work when only .default is provided', function (done) {115 request(app5)116 .get('/')117 .set('Accept', '*/*')118 .expect('hey', done);119 })120 })121122 describe('in router', function(){123 test(app4);
90 unmodified lines
modified:History.md+1 added
1unreleased2==========34 * Fix `res.format` error when only `default` provided5 * Fix issue where `next('route')` in `app.param` would incorrectly skip values6 * Use `array-flatten` module for flattening arrays7 * deps: accepts@~1.2.98 - deps: mime-types@~2.1.1
2942 unmodified lines