From 03a60831b4aba72548c4e7461116f24ced38c492 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 25 Sep 2014 22:47:04 +0100 Subject: [PATCH] fix lat error --- sanitiser/_latlonzoom.js | 10 +++++----- test/unit/sanitiser/sanitise.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sanitiser/_latlonzoom.js b/sanitiser/_latlonzoom.js index 5120074d..d1a17033 100644 --- a/sanitiser/_latlonzoom.js +++ b/sanitiser/_latlonzoom.js @@ -11,11 +11,11 @@ function sanitize( req ){ // lat var lat = parseFloat( params.lat, 10 ); - if( isNaN( lat ) || lat < 0 || lat > 90 ){ + if( isNaN( lat ) || lat < -90 || lat > 90 ){ return { 'error': true, - 'message': 'invalid param \'lat\': must be >0 and <90' - } + 'message': 'invalid param \'lat\': must be >-90 and <90' + }; } clean.lat = lat; @@ -24,8 +24,8 @@ function sanitize( req ){ if( isNaN( lon ) || lon < -180 || lon > 180 ){ return { 'error': true, - 'message': 'invalid param \'lon\': must be >-180 and <180' - } + 'message': 'invalid param \'lon\': must be >-180 and <180' + }; } clean.lon = lon; diff --git a/test/unit/sanitiser/sanitise.js b/test/unit/sanitiser/sanitise.js index bb1402ec..b183d2f9 100644 --- a/test/unit/sanitiser/sanitise.js +++ b/test/unit/sanitiser/sanitise.js @@ -50,13 +50,13 @@ module.exports.tests.sanitize_input = function(test, common) { module.exports.tests.sanitize_lat = function(test, common) { var lats = { - invalid: [ -1, -45, -90, 91, 120, 181 ], + invalid: [ -181, -120, -91, 91, 120, 181 ], valid: [ 0, 45, 90, -0, '0', '45', '90' ] }; lats.invalid.forEach( function( lat ){ test('invalid lat', function(t) { sanitize({ input: 'test', lat: lat, lon: 0 }, function( err, clean ){ - t.equal(err, 'invalid param \'lat\': must be >0 and <90', 'invalid latitude'); + t.equal(err, 'invalid param \'lat\': must be >-90 and <90', 'invalid latitude'); t.equal(clean, undefined, 'clean not set'); t.end(); });