Skip to content
Myr

refactored `req.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 7eec21a · Browse files · 1 file+8 added−8 removed
This commit

State

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

Diff stats

1 file+8 added−8 removed

  • other:+8 added−8 removed

1 file+8 added−8 removed

modified:lib/request.js+8 added-8 removed
138 unmodified lines
139 if (~accept.indexOf(type)) return true;140141 // check if we have type/*142 type = type.split('/')[0] + '/*';143 return !!~accept.indexOf(type);143 return !! ~accept.indexOf(type);144 } else {145 return false;146 }147};
16 unmodified lines
164 */165166req.param = function(name, defaultValue){167 // route params like /user/:id168 if (this.params && this.params.hasOwnProperty(name) && undefined !== this.params[name]) {168 if (this.params169 && this.params.hasOwnProperty(name)170 && undefined !== this.params[name]) {171 return this.params[name]; 172 }173 // query string params172 if (undefined !== this.query[name]) {173 return this.query[name]; 174 }174 if (undefined !== this.query[name]) return this.query[name]; 175176 // request body params via connect.bodyParser176 if (this.body && undefined !== this.body[name]) {177 return this.body[name];178 }177 if (this.body && undefined !== this.body[name]) return this.body[name];178179 return defaultValue;180};181182/**
140 unmodified lines