From a4d09f8e129240d21ac8bd8364bca4605b432e0a Mon Sep 17 00:00:00 2001 From: Harish Krishna Date: Thu, 16 Jul 2015 13:27:20 -0400 Subject: [PATCH] no address parsing required if there are only 2 or less tokens --- sanitiser/_input.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sanitiser/_input.js b/sanitiser/_input.js index f79d5683..2128f91e 100644 --- a/sanitiser/_input.js +++ b/sanitiser/_input.js @@ -38,10 +38,15 @@ function sanitize( req ){ parsedAddress0.admin_parts = params.input.substring(delimIndex + 1).trim(); } - // set target_layer if input length < 3 characters - if (params.input.length <= 3) { + var splitOnSpace = params.input.split(' '); + var splitOnDelim = params.input.split(delim); + // set target_layer if input length <= 3 characters + if (params.input.length <= 3 ) { // no address parsing required parsedAddress2.target_layer = get_layers(['admin']); + } else if (splitOnDelim.length < 3 || splitOnSpace.length < 3) { + // no need to hit address layers if there's only two tokens + parsedAddress2.target_layer = get_layers(['admin', 'poi']); } else { // address parsing parsedAddress1 = parser( params.input );