Browse Source

Merge pull request #21 from pelias/fix_lat

fix lat error
pull/25/head
Harish Krishna 10 years ago
parent
commit
a6aebe9e78
  1. 10
      sanitiser/_latlonzoom.js
  2. 4
      test/unit/sanitiser/sanitise.js

10
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;

4
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();
});

Loading…
Cancel
Save