Browse Source

fix(libpostal): check for next element before using it

libpostal_aus_unit_numbers
Julian Simioni 6 years ago
parent
commit
ee43ec041c
No known key found for this signature in database
GPG Key ID: B9EEB0C6EE0910A1
  1. 2
      controller/libpostal.js

2
controller/libpostal.js

@ -150,7 +150,7 @@ function patchBuggyResponses(response){
if( _.isPlainObject(road) && _.isString(road.value) && road.value.length === 2 ){
if( DIAGONAL_DIRECTIONALS.includes( road.value.toLowerCase() ) ){
let subsequentElement = response[road._pos+1];
if( _.isString(subsequentElement.value) ){
if( subsequentElement && _.isString(subsequentElement.value) ){
response[road._pos].value += ' ' + subsequentElement.value; // merge elements
response.splice(road._pos+1, 1); // remove merged element
}

Loading…
Cancel
Save