Browse Source

Named admin_parts adminParts which caused problems

pull/502/head
Diana Shkolnikov 9 years ago
parent
commit
c415b96ead
  1. 13
      helper/text_parser.js
  2. 2
      test/unit/helper/text_parser.js

13
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 + ' ');
}

2
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');

Loading…
Cancel
Save