Skip to content
Myr

Fixed call to app.param() function for optional params. Closes #682

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 1ce43dd · Browse files · 3 files+7 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

3 files+7 added−7 removed

  • tests:+2 added−2 removed
  • other:+5 added−5 removed

3 files+7 added−7 removed

modified:lib/router/index.js+4 added-4 removed
207 unmodified lines
208 i = 0;209210 (function param(err) {211 var key = keys[i++]212 , val = req.params[key]213 , fn = params[key]212 , val = key && req.params[key.name]213 , fn = key && params[key.name]214 , ret;215216 try {217 if ('route' == err) {218 nextRoute();219 } else if (err) {220 next(err);221 } else if (fn) {221 } else if (fn && undefined !== val) {222 fn(req, res, param, val);223 } else if (key) {224 param();225 } else {
102 unmodified lines
328 , val = 'string' == typeof captures[j]329 ? decodeURIComponent(captures[j])330 : captures[j];331 if (key) {332 route.params[key] = val;332 route.params[key.name] = val;333 } else {334 route.params.push(val);335 }336 }
47 unmodified lines
modified:lib/router/route.js+1 added-1 removed
modified:test/router.test.js+2 added-2 removed
227 unmodified lines
228 route.callback.should.be.a('function');229 route.path.should.equal('/user/:id');230 route.regexp.should.be.an.instanceof(RegExp);231 route.method.should.equal('get');232 route.keys.should.eql(['id']);232 route.keys.should.eql([{ name: 'id', optional: false }]);233234 app.get('/user').should.have.length(1);235 app.get('/user/:id').should.have.length(1);236 app.get('/user/:id/:op?').should.have.length(1);
53 unmodified lines
290 route.callback.should.be.a('function');291 route.path.should.equal('/user/:id');292 route.regexp.should.be.an.instanceof(RegExp);293 route.method.should.equal('get');294 route.keys.should.eql(['id']);294 route.keys.should.eql([{ name: 'id', optional: false }]);295 //route.params.id.should.equal('12');296297 app.match.get('/user').should.have.length(1);298 app.match.get('/user/12').should.have.length(2);
65 unmodified lines