Skip to content
Myr

Moved param() retval logic to Router#param()

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 85df59a · Browse files · 2 files+15 added−9 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+15 added−9 removed

  • other:+15 added−9 removed

2 files+15 added−9 removed

modified:lib/router/index.js+15 added-8 removed
52 unmodified lines
53 * @api public54 */5556Router.prototype.param = function(name, fn){57 var callback = fn;5859 if (fn.length < 3) {60 fn = function(req, res, next){61 var val = req.params[name];62 val = req.params[name] = callback(val);63 if (invalidParamReturnValue(val)) {64 next('route');65 } else {66 next();67 }68 };69 }7071 this.params[name] = fn;72 return this;73};74
131 unmodified lines
206 if ('route' == err) {207 nextRoute();208 } else if (err) {209 next(err);196 } else if (fn && fn.length < 3) {197 ret = req.params[key] = fn(val);198 if (invalidParamReturnValue(ret)) {199 nextRoute();200 } else {201 param();202 }210 } else if (fn) {211 fn(req, res, param, val);212 } else if (key) {213 param();
172 unmodified lines
386function invalidParamReturnValue(val){387 return null == val388 || false === val389 || ('number' == typeof val && isNaN(val));383};390};
modified:lib/http.js-1 removed
530 unmodified lines
531// del -> delete alias532533app.del = app.delete;534535