From 176f580215f363e1b37e2b9255a01e1c9d0e42cd Mon Sep 17 00:00:00 2001 From: Harish Krishna Date: Wed, 22 Apr 2015 18:00:41 -0400 Subject: [PATCH] using is-object --- sanitiser/_details.js | 4 +++- sanitiser/_geo.js | 4 +++- sanitiser/_id.js | 4 +++- sanitiser/_input.js | 4 +++- sanitiser/_size.js | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sanitiser/_details.js b/sanitiser/_details.js index 0e45b8cb..3d6f0165 100644 --- a/sanitiser/_details.js +++ b/sanitiser/_details.js @@ -1,3 +1,5 @@ +var isObject = require('is-object'); + // validate inputs, convert types and apply defaults function sanitize( req, default_value ){ @@ -11,7 +13,7 @@ function sanitize( req, default_value ){ default_value = !!default_value; // ensure the input params are a valid object - if( Object.prototype.toString.call( params ) !== '[object Object]' ){ + if( !isObject( params ) ){ params = {}; } diff --git a/sanitiser/_geo.js b/sanitiser/_geo.js index 2b7106af..517f1c24 100644 --- a/sanitiser/_geo.js +++ b/sanitiser/_geo.js @@ -1,3 +1,5 @@ +var isObject = require('is-object'); + // validate inputs, convert types and apply defaults function sanitize( req, latlon_is_required ){ @@ -6,7 +8,7 @@ function sanitize( req, latlon_is_required ){ latlon_is_required = latlon_is_required || false; // ensure the input params are a valid object - if( Object.prototype.toString.call( params ) !== '[object Object]' ){ + if( !isObject( params ) ){ params = {}; } diff --git a/sanitiser/_id.js b/sanitiser/_id.js index b19f0696..ac2432e6 100644 --- a/sanitiser/_id.js +++ b/sanitiser/_id.js @@ -1,3 +1,5 @@ +var isObject = require('is-object'); + // validate inputs, convert types and apply defaults // id generally looks like 'geoname:4163334' (type:id) // so, both type and id are required fields. @@ -10,7 +12,7 @@ function sanitize( req ){ var delim = ':'; // ensure params is a valid object - if( Object.prototype.toString.call( params ) !== '[object Object]' ){ + if( !isObject( params ) ){ params = {}; } diff --git a/sanitiser/_input.js b/sanitiser/_input.js index b1de5e63..20576ed2 100644 --- a/sanitiser/_input.js +++ b/sanitiser/_input.js @@ -1,3 +1,5 @@ +var isObject = require('is-object'); + // validate inputs, convert types and apply defaults function sanitize( req ){ @@ -6,7 +8,7 @@ function sanitize( req ){ var delim = ','; // ensure the input params are a valid object - if( Object.prototype.toString.call( params ) !== '[object Object]' ){ + if( !isObject( params ) ){ params = {}; } diff --git a/sanitiser/_size.js b/sanitiser/_size.js index 6db87aaf..c0101727 100644 --- a/sanitiser/_size.js +++ b/sanitiser/_size.js @@ -1,3 +1,5 @@ +var isObject = require('is-object'); + // validate inputs, convert types and apply defaults function sanitize( req, default_size){ @@ -7,7 +9,7 @@ function sanitize( req, default_size){ default_size = default_size || 10; // ensure the input params are a valid object - if( Object.prototype.toString.call( params ) !== '[object Object]' ){ + if( !isObject( params ) ){ params = {}; }