|
|
@ -18,16 +18,7 @@ function sanitize( req, default_value ){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (params.details !== undefined) { |
|
|
|
if (params.details !== undefined) { |
|
|
|
var details = params.details; |
|
|
|
clean.details = isTruthy(params.details); |
|
|
|
|
|
|
|
|
|
|
|
if (typeof params.details === 'string') { |
|
|
|
|
|
|
|
details = params.details === 'true' || |
|
|
|
|
|
|
|
params.details === '1' || |
|
|
|
|
|
|
|
params.details === 'yes' || |
|
|
|
|
|
|
|
params.details === 'y'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clean.details = details === true || details === 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
clean.details = default_value; |
|
|
|
clean.details = default_value; |
|
|
|
} |
|
|
|
} |
|
|
@ -38,5 +29,13 @@ function sanitize( req, default_value ){ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isTruthy(val) { |
|
|
|
|
|
|
|
if (typeof val === 'string') { |
|
|
|
|
|
|
|
return ['true', '1', 'yes', 'y'].indexOf(val) !== -1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return val === 1 || val === true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// export function
|
|
|
|
// export function
|
|
|
|
module.exports = sanitize; |
|
|
|
module.exports = sanitize; |
|
|
|