diff --git a/helper/text_parser.js b/helper/text_parser.js index dcce1f63..0db8bede 100644 --- a/helper/text_parser.js +++ b/helper/text_parser.js @@ -24,20 +24,15 @@ module.exports.get_parsed_address = function get_parsed_address(query) { // naive approach - for admin matching during query time // split 'flatiron, new york, ny' into 'flatiron' and 'new york, ny' - //var delimIndex = query.indexOf(DELIM); - //var address = {}; - //if ( delimIndex !== -1 ) { - // address.name = query.substring(0, delimIndex); - // address.admin_parts = query.substring(delimIndex + 1).trim(); - //} - - var address = {}; if (queryParts.length > 1) { address.name = queryParts[0].trim(); - address.adminParts = queryParts.slice(1) + // 1. slice away all parts after the first one + // 2. trim spaces from each part just in case + // 3. join the parts back together with appropriate delimiter and spacing + address.admin_parts = queryParts.slice(1) .map(function (part) { return part.trim(); }) .join(DELIM + ' '); } diff --git a/test/unit/helper/text_parser.js b/test/unit/helper/text_parser.js index 93bd4a97..d85deca1 100644 --- a/test/unit/helper/text_parser.js +++ b/test/unit/helper/text_parser.js @@ -119,8 +119,6 @@ module.exports.tests.parse_address = function(test, common) { var query_string = '339 W Main St,Lancaster,PA'; var address = parser.get_parsed_address(query_string); - console.log(address); - t.equal(typeof address, 'object', 'valid object for the address'); t.equal(address.number, '339', 'parsed house number'); t.equal(address.street, 'W Main St', 'parsed street');