OpenCageData / address-formatting

templates to format geographic addresses
MIT License
394 stars 84 forks source link

CA postformat_replace has side effects #91

Closed StephanGeorg closed 1 year ago

StephanGeorg commented 1 year ago

Canadian postformat_replace regex (\\w{2}) (\\w{3})(\\w{3})\n has side effects when applied to abbreviated street types:

Input

{
  "road": "Av Demars",
  "house_number": "12345",
  "postcode": "J2T 3T5",
  "city": "St-Hyancinth",
  "countryCode" : "CA"
}

Output

{
  "formattedAddress": [
     "12345 Av Dem ars",
     "St-Hyancinth, J2T 3T5"
  ]
}

Solution Replace postformat_replace with more strict postal code regex: ([A-Za-z]{2}) ([A-Za-z]\\d[A-Za-z])(\\d[A-Za-z]\\d)

freyfogle commented 1 year ago

well spotted. can you submit a pull request. Ideally with a test case in testcases/countries/ca.yaml please