Skip to content
Myr

Remove ":" stripping from app.param()

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 b309b87 · Browse files · 3 files+7 added−10 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−10 removed

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

3 files+7 added−10 removed

modified:lib/router/index.js-5 removed
104 unmodified lines
105 var params = this._params;106 var len = params.length;107 var ret;108109 if (name[0] === ':') {110 deprecate('router.param(' + JSON.stringify(name) + ', fn): Use router.param(' + JSON.stringify(name.substr(1)) + ', fn) instead');111 name = name.substr(1);112 }113109 for (var i = 0; i < len; ++i) {110 if (ret = params[i](name, fn)) {111 fn = ret;112 }
525 unmodified lines
modified:test/app.param.js+4 added-5 removed
19 unmodified lines
20 }21 }22 })2324 app.param(':name', /^([a-zA-Z]+)$/);24 app.param('name', /^([a-zA-Z]+)$/);2526 app.get('/user/:name', function(req, res){27 res.send(req.params.name);28 });2930 request(app)31 .get('/user/tj')32 .end(function(err, res){33 res.text.should.equal('tj');32 .expect(200, 'tj', function (err) {33 if (err) return done(err);34 request(app)35 .get('/user/123')36 .expect(404, done);37 });3838 })3940 it('should fail if not given fn', function(){41 var app = express();43 app.param.bind(app, ':name', 'bob').should.throw();42 app.param.bind(app, 'name', 'bob').should.throw();43 })44 })4546 describe('.param(names, fn)', function(){
320 unmodified lines
modified:History.md+3 added
1 unmodified line
2===34This incorporates all changes after 4.10.1 up to 4.13.1.56 * change:7 - The leading `:` character in `name` for `app.param(name, fn)` is no longer removed895.0.0-alpha.1 / 2014-11-0610==========================1112This is the first Express 5.0 alpha release, based off 4.10.1.
3009 unmodified lines