mirror of https://github.com/pelias/api.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
677 B
28 lines
677 B
// validate inputs, convert types and apply defaults |
|
function sanitize( req, default_value ){ |
|
|
|
var clean = req.clean || {}; |
|
var params= req.query; |
|
|
|
default_value = !!default_value; |
|
|
|
// ensure the input params are a valid object |
|
if( Object.prototype.toString.call( params ) !== '[object Object]' ){ |
|
params = {}; |
|
} |
|
|
|
if (params.details !== undefined) { |
|
var details = typeof params.details === 'string' ? params.details === 'true' : params.details; |
|
clean.details = details === true || details === 1; |
|
} else { |
|
clean.details = default_value; |
|
} |
|
|
|
req.clean = clean; |
|
|
|
return {'error':false}; |
|
|
|
} |
|
|
|
// export function |
|
module.exports = sanitize;
|
|
|