Skip to content
Myr

Merge pull request #1835 from visionmedia/change-req-params-to-object

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

change req.params to an object instead of an array

authored by Jonathan Ong · committed by Jonathan Ong · parents 26c0be4, c6c71ab · 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
150 unmodified lines
151 it('should populate req.params with the captures', function(done){152 var app = express();153154 app.get(/^\/user\/([0-9]+)\/(view|edit)?$/, function(req, res){155 var id = req.params.shift()156 , op = req.params.shift();155 var id = req.params[0]156 , op = req.params[1];157 res.end(op + 'ing user ' + id);158 });159160 request(app)
166 unmodified lines
327 it('should work with several', function(done){328 var app = express();329330 app.get('/api/*.*', function(req, res){331 var resource = req.params.shift()332 , format = req.params.shift();331 var resource = req.params[0]332 , format = req.params[1];333 res.end(resource + ' as ' + format);334 });335336 request(app)
288 unmodified lines