Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly parse address1 ending in US Route number #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ module.exports = {
'( +(?:' + usStreetDirectionalString + ')\\b)?', 'i');
var rePO = new RegExp('(P\\.?O\\.?|POST\\s+OFFICE)\\s+(BOX|DRAWER)\\s\\w+', 'i');
var reAveLetter = new RegExp('\.\*\\b(ave.?|avenue)\.\*\\b[a-zA-Z]\\b', 'i');
var reNoSuffix = new RegExp('\\b\\d+[a-z]?\\s[a-zA-Z0-9_ ]+\\b', 'i');
var reNoSuffix = new RegExp("\\b\\d+[a-z]?\\s[a-zA-Z0-9_ -]+\\b", "i");

if (streetString.match(reAveLetter)) {
result.addressLine1 = streetString.match(reAveLetter)[0];
streetString = streetString.replace(reAveLetter,"").trim(); // Carve off the first address line
Expand Down
14 changes: 14 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,20 @@ describe('#parseAddress', function() {
expect(result).to.not.have.property("zipCode");
expect(result).to.not.have.property("zipCodePlusFour");
});

it('should parse an address1 ending with a US Route', function() {
var result = addresser.parseAddress("737 US-42, Ashland, OH 44805");
expect(result.streetNumber).to.equal("737");
expect(result.streetName).to.equal("US-42");
expect(result).to.not.have.property('streetSuffix')
expect(result.addressLine1).to.equal("737 US-42");
expect(result).to.not.have.property('addressLine2')
expect(result.placeName).to.equal("Ashland");
expect(result.stateAbbreviation).to.equal("OH");
expect(result.stateName).to.equal("Ohio");
expect(result.zipCode).to.equal("44805")
expect(result).to.not.have.property("zipCodePlusFour");
});

it('should parse FM number style road names', function() {
var result = addresser.parseAddress("11434 W FM 471, San Antonio, TX");
Expand Down