Skip to content
Myr

Fix inner numeric indices incorrectly altering parent req.params

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

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent ee90042 · Browse files · 3 files+22 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+22 added−1 removed

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

3 files+22 added−1 removed

modified:lib/router/index.js+1 added-1 removed
594 unmodified lines
595 delete params[i];596 }597 }598599 return mixin(parent, params);599 return mixin(obj, params);600}601602// restore obj props after function603function restore(fn, obj) {
42 unmodified lines
modified:test/app.router.js+20 added
352 unmodified lines
353 request(app)354 .get('/user/tj')355 .expect(200, '[["name","tj"]]', done);356 })357358 it('should restore req.params', function(done){359 var app = express();360 var router = new express.Router({ mergeParams: true });361362 router.get('/user:(\\w+)/*', function (req, res, next) {363 next();364 });365366 app.use('/user/id:(\\d+)', function (req, res, next) {367 router(req, res, function (err) {368 var keys = Object.keys(req.params).sort();369 res.send(keys.map(function(k){ return [k, req.params[k]] }));370 });371 });372373 request(app)374 .get('/user/id:42/user:tj/profile')375 .expect(200, '[["0","42"]]', done);376 })377 })378379 describe('trailing slashes', function(){380 it('should be optional by default', function(done){
654 unmodified lines
modified:History.md+1 added
1unreleased2==========34 * Fix infinite loop condition using `mergeParams: true`5 * Fix inner numeric indices incorrectly altering parent `req.params`674.13.2 / 2015-07-318===================9
3016 unmodified lines