Comparing version 1.2.1 to 1.3.0
@@ -5,3 +5,3 @@ { | ||
"description": "Freeform Street Address Parser", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"main": "index.js", | ||
@@ -8,0 +8,0 @@ "scripts": [ |
@@ -55,3 +55,3 @@ /* jshint node: true */ | ||
// if no locale has been specified, then use the default vanilla en locale | ||
var parse = (opts || {}).locale || require('./parsers/en'); | ||
var parse = (opts || {}).locale || require('./locale/en-US'); | ||
@@ -58,0 +58,0 @@ // parse the address |
@@ -6,7 +6,11 @@ var parser = require('../parsers/en.js'); | ||
// parse the base address | ||
return parser(input, extend({ rePostalCode: /((?:[1-8][0-9]|9[0-7]|0?[28]|0?9(?=09))(?:[0-9]{2}))\s*$/ }, opts)); | ||
// Postal codes of the form 'DDDD', with the first | ||
// two digits 02, 08 or 20-97. Leading 0 may be omitted. | ||
// 909 and 0909 are valid as well - but no other postal | ||
// codes starting with 9 or 09. | ||
return parser(input, extend({ | ||
country: { | ||
AUS: /^AUSTRALIA|^A\.?U\.?S?$/i | ||
}, | ||
rePostalCode: /((?:[1-8][0-9]|9[0-7]|0?[28]|0?9(?=09))(?:[0-9]{2}))\s*$/ }, opts)); | ||
// Postal codes of the form 'DDDD', with the first | ||
// two digits 02, 08 or 20-97. Leading 0 may be omitted. | ||
// 909 and 0909 are valid as well - but no other postal | ||
// codes starting with 9 or 09. | ||
}; |
@@ -6,3 +6,3 @@ { | ||
"author": "Damon Oehlman <damon.oehlman@gmail.com>", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"repository": { | ||
@@ -19,3 +19,3 @@ "type": "git", | ||
"devDependencies": { | ||
"tape": "^3.5.0" | ||
"tape": "^4.0.1" | ||
}, | ||
@@ -22,0 +22,0 @@ "scripts": { |
@@ -109,12 +109,13 @@ /* jshint node: true */ | ||
// extract the country | ||
// TODO: move this to the locale | ||
.extract('country', { | ||
AU: /^AUSTRAL/, | ||
US: /(^UNITED\sSTATES|^U\.?S\.?A?$)/ | ||
}) | ||
// extract the street | ||
.extractStreet(streetRegexes, reSplitStreet); | ||
if (opts && opts.state) { | ||
address.extract('state', opts.state ); | ||
} | ||
if (opts && opts.country) { | ||
address.extract('country', opts.country ); | ||
} | ||
if (opts && opts.rePostalCode) { | ||
@@ -121,0 +122,0 @@ address.extract('postalcode', [ opts.rePostalCode ]); |
require('./parse'); | ||
require('./postalcode-en-AU'); | ||
require('./locale-en-AU'); | ||
require('./locale-en-US'); | ||
require('./street-types'); |
@@ -23,3 +23,3 @@ var test = require('tape'); | ||
street: "N 2nd St", | ||
regions: ["San Jose", "CA"] | ||
regions: ["San Jose"] | ||
})); | ||
@@ -72,3 +72,3 @@ | ||
"street": "Hawthorn Dr", | ||
"regions": ["St Charles", "IL"] | ||
"regions": ["St Charles"] | ||
})); | ||
@@ -75,0 +75,0 @@ |
73876
21
1321