Skip to content
Myr

change req.params to an object instead of an array

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 863160a · Browse files · 2 files+8 added−7 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+8 added−7 removed

  • tests:+4 added−4 removed
  • other:+4 added−3 removed

2 files+8 added−7 removed

modified:lib/router/route.js+4 added-3 removed
modified:test/app.router.js+4 added-4 removed
124 unmodified lines
125 it('should populate req.params with the captures', function(done){126 var app = express();127128 app.get(/^\/user\/([0-9]+)\/(view|edit)?$/, function(req, res){129 var id = req.params.shift()130 , op = req.params.shift();129 var id = req.params[0]130 , op = req.params[1];131 res.end(op + 'ing user ' + id);132 });133134 request(app)
166 unmodified lines
301 it('should work with several', function(done){302 var app = express();303304 app.get('/api/*.*', function(req, res){305 var resource = req.params.shift()306 , format = req.params.shift();305 var resource = req.params[0]306 , format = req.params[1];307 res.end(resource + ' as ' + format);308 });309310 request(app)
288 unmodified lines