Skip to content

Commit

Permalink
Update req.js
Browse files Browse the repository at this point in the history
for example if you posted data `{ isPirate: false }` and you run `req.param('isPirate')` from a controller, you'd get `undefined` returned as you didn't specify a `defaultValue` - so basically you couldn't post params that where === false. I think this edit captures the spirit of the OR guard used previously.
  • Loading branch information
jub3i committed Mar 17, 2015
1 parent 131cbc2 commit f0cf3b3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/router/req.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ module.exports = function buildRequest (_req) {

// Grab the value of the parameter from the appropriate place
// and return it
return params[paramName] || defaultValue;
if (typeof params[paramName] !== 'undefined') {
return params[paramName];
} else {
return defaultValue;
}

},
wantsJSON: (_req && _req.wantsJSON) || true,
method: 'GET'
Expand Down

0 comments on commit f0cf3b3

Please sign in to comment.