Skip to content
Myr

Fixed multiple param callback regression. Closes #824 [reported by TroyGoode]

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 0534266 · Browse files · 2 files+34 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+34 added−1 removed

  • tests:+32 added−0 removed
  • other:+2 added−1 removed

2 files+34 added−1 removed

modified:lib/router/index.js+2 added-1 removed
224 unmodified lines
225 i = 0;226227 // param callbacks228 function param(err) {229 paramIndex = 0;230 key = keys[i++];231 paramVal = key && req.params[key.name];232 paramCallbacks = key && params[key.name];232 233234 try {235 if ('route' == err) {236 nextRoute();237 } else if (err) {
161 unmodified lines
modified:test/router.test.js+32 added
799 unmodified lines
800801 assert.response(app,802 { url: '/user/12' },803 { body: 'recovered from error: fail' });804 },805 806 'test multiple param callbacks': function(){807 var app = express.createServer();808809 app.param('user', function(req, res, next, id){810 req.user = { id: id };811 next();812 });813814 app.param('forum_id', function(req, res, next, id){815 req.forum = { id: id };816 next();817 });818819 app.param('thread_id', function(req, res, next, id){820 req.thread = { id: id };821 next();822 });823824 function array(req, res, next) {825 req.arr = [req.user.id, req.forum.id, req.thread.id];826 next();827 }828829 app.get('/:user/:forum_id/:thread_id', array, function(req, res){830 res.send(req.arr);831 });832833 assert.response(app,834 { url: '/1/2/3' },835 { body: '["1","2","3"]' });836 }837};