Browse Source

fix comments and tests

pull/117/head
Diana Shkolnikov 10 years ago
parent
commit
6ae1a4f7df
  1. 2
      DOCS.md
  2. 6
      sanitiser/_geo.js
  3. 8
      test/unit/sanitiser/search.js
  4. 8
      test/unit/sanitiser/suggest.js

2
DOCS.md

@ -19,7 +19,7 @@ Full text search endpoint which queries the elasticsearch doc store, slightly sl
* **bbox**: the bounding box from which you want all your results to come * **bbox**: the bounding box from which you want all your results to come
* can be one of the following comma separated string values * can be one of the following comma separated string values
* "southwest_lng,southwest_lat,northeast_lng,northeast_lat" ```L.latLngBounds(southwestLatLng, northeastLatLng).toBBoxString()``` * "southwest_lng,southwest_lat,northeast_lng,northeast_lat" ```L.latLngBounds(southwestLatLng, northeastLatLng).toBBoxString()```
* bottom left lat, bottom left lon, top right lat, top right lon * bottom left lon, bottom left lat, top right lon, top right lat
* left, bottom, right, top * left, bottom, right, top
* min longitude, min latitude, max longitude, max latitude * min longitude, min latitude, max longitude, max latitude
* **details**: indicates if results should contain detailed, should be `true` or `false` * **details**: indicates if results should contain detailed, should be `true` or `false`

6
sanitiser/_geo.js

@ -34,9 +34,9 @@ module.exports = function sanitize( req, latlon_is_required ){
/** /**
* Parse and validate bbox parameter * Parse and validate bbox parameter
* bbox = bottom_left lat, bottom_left lon, top_right lat, top_right lon * bbox = bottom_left lon, bottom_left lat, top_right lon, top_right lat
* bbox = bottom, left, top, right * bbox = bottom, left, top, right
* bbox = min Latitude , min Longitude , max Latitude , max Longitude * bbox = min Longitude, min Latitude, max Longitude, max Latitude
* *
* @param {object} clean * @param {object} clean
* @param {string} param * @param {string} param
@ -53,7 +53,7 @@ function sanitize_bbox( clean, param ) {
bbox = bboxArr.filter( function( latlon, index ) { bbox = bboxArr.filter( function( latlon, index ) {
latlon = parseFloat( latlon, 10 ); latlon = parseFloat( latlon, 10 );
return !(lat_lon_checks[(index % 2 === 0 ? 'lat' : 'lon')].is_invalid( latlon )); return !(lat_lon_checks[(index % 2 === 0 ? 'lon' : 'lat')].is_invalid( latlon ));
}); });
if( bbox.length === 4 ) { if( bbox.length === 4 ) {

8
test/unit/sanitiser/search.js

@ -168,9 +168,9 @@ module.exports.tests.sanitize_optional_geo = function(test, common) {
module.exports.tests.sanitize_bbox = function(test, common) { module.exports.tests.sanitize_bbox = function(test, common) {
var bboxes = { var bboxes = {
invalid_coordinates: [ invalid_coordinates: [
'90,-181,-180,34', // invalid top_right lon, bottom_left lat '-181,90,34,-180', // invalid top_right lon, bottom_left lat
'91,-170,45,-181', // invalid top_right lat, bottom_left lon '-170,91,-181,45', // invalid top_right lat, bottom_left lon
'91,-181,-91,181', // invalid top_right lat/lon, bottom_left lat/lon '-181,91,181,-91', // invalid top_right lon/lat, bottom_left lon/lat
'91, -181,-91,181',// invalid - spaces between coordinates '91, -181,-91,181',// invalid - spaces between coordinates
], ],
invalid: [ invalid: [
@ -180,7 +180,7 @@ module.exports.tests.sanitize_bbox = function(test, common) {
'' // invalid - empty param '' // invalid - empty param
], ],
valid: [ valid: [
'90,-179,-80,34', // valid top_right lat/lon, bottom_left lat/lon '-179,90,34,-80', // valid top_right lon/lat, bottom_left lon/lat
'0,0,0,0' // valid top_right lat/lon, bottom_left lat/lon '0,0,0,0' // valid top_right lat/lon, bottom_left lat/lon
] ]

8
test/unit/sanitiser/suggest.js

@ -137,9 +137,9 @@ module.exports.tests.sanitize_lon = function(test, common) {
module.exports.tests.sanitize_bbox = function(test, common) { module.exports.tests.sanitize_bbox = function(test, common) {
var bboxes = { var bboxes = {
invalid_coordinates: [ invalid_coordinates: [
'90,-181,-180,34', // invalid top_right lon, bottom_left lat '-181,90,34,-180', // invalid top_right lon, bottom_left lat
'91,-170,45,-181', // invalid top_right lat, bottom_left lon '-170,91,-181,45', // invalid top_right lat, bottom_left lon
'91,-181,-91,181', // invalid top_right lat/lon, bottom_left lat/lon '-181,91,181,-91', // invalid top_right lon/lat, bottom_left lon/lat
'91, -181,-91,181',// invalid - spaces between coordinates '91, -181,-91,181',// invalid - spaces between coordinates
], ],
invalid: [ invalid: [
@ -149,7 +149,7 @@ module.exports.tests.sanitize_bbox = function(test, common) {
'' // invalid - empty param '' // invalid - empty param
], ],
valid: [ valid: [
'90,-179,-80,34', // valid top_right lat/lon, bottom_left lat/lon '-179,90,34,-80', // valid top_right lon/lat, bottom_left lon/lat
'0,0,0,0' // valid top_right lat/lon, bottom_left lat/lon '0,0,0,0' // valid top_right lat/lon, bottom_left lat/lon
] ]

Loading…
Cancel
Save