|
|
@ -38,14 +38,15 @@ function sanitize( req ){ |
|
|
|
parsedAddress0.admin_parts = params.input.substring(delimIndex + 1).trim(); |
|
|
|
parsedAddress0.admin_parts = params.input.substring(delimIndex + 1).trim(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var splitOnDelim = params.input.split(delim).join(''); |
|
|
|
var tokenized = params.input.split(/[ ,]+/); |
|
|
|
var splitOnSpace = delim !== ' ' ? splitOnDelim.split(' ') : splitOnDelim; |
|
|
|
var hasNumber = /\d$/.test(params.input); |
|
|
|
|
|
|
|
|
|
|
|
// set target_layer if input length <= 3 characters
|
|
|
|
// set target_layer if input length <= 3 characters
|
|
|
|
if (params.input.length <= 3 ) { |
|
|
|
if (params.input.length <= 3 ) { |
|
|
|
// no address parsing required
|
|
|
|
// no address parsing required
|
|
|
|
parsedAddress2.target_layer = get_layers(['admin']); |
|
|
|
parsedAddress2.target_layer = get_layers(['admin']); |
|
|
|
} else if (splitOnSpace.length < 3) { |
|
|
|
} else if (tokenized.length === 1 || (tokenized.length < 3 && !hasNumber)) { |
|
|
|
// no need to hit address layers if there's only two tokens
|
|
|
|
// no need to hit address layers if there's only one (or two) token(s)
|
|
|
|
parsedAddress2.target_layer = get_layers(['admin', 'poi']); |
|
|
|
parsedAddress2.target_layer = get_layers(['admin', 'poi']); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// address parsing
|
|
|
|
// address parsing
|
|
|
|