Skip to content

Commit

Permalink
fix: Merge pull request #130 from pelias/normalize-street-names
Browse files Browse the repository at this point in the history
Removing the extra white space from the middle of street names
  • Loading branch information
avulfson17 authored Jun 29, 2016
2 parents 1e63764 + 0959d5e commit f55c5c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ function removeLeadingZerosFromStreet(token) {
}

function cleanupStreetName(input) {
var street_parts = input.split(' ');
return street_parts.map(removeLeadingZerosFromStreet).join(' ');
return input.split(/\s/)
.map(removeLeadingZerosFromStreet)
.filter(function(part){
return part.length > 0;
}).join(' ');
}

module.exports = {
Expand Down
14 changes: 14 additions & 0 deletions test/streams/cleanupStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,17 @@ tape( 'cleanupStream trims leading 0\'s from house numbers', function(test) {
});

});

tape ( 'cleanupStream trims white space in street field', function(test){
var input = {
STREET: '34 West\t 93rd \nst'
};

var cleanupStream = CleanupStream.create();

test_stream([input],cleanupStream, function(err,records){
test.equal(records.length, 1, 'stream length unchanged');
test.equal(records[0].STREET, '34 West 93rd st');
test.end();
});
});

0 comments on commit f55c5c3

Please sign in to comment.