Skip to content

Commit

Permalink
Detect also country parsing mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
vesameskanen committed Jun 10, 2022
1 parent 79046f5 commit 68c34c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sanitizer/_text_addressit.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ function assignValidLibpostalParsing(parsedText, fromLibpostal, text) {
}
}

// parser often misinterprets partial text (la, ny, etc) as US state
// parser often misinterprets partial text (la, ny, etc) as US state or country
// we should reprogram parsing database with finnish addresses only!
const state = fromLibpostal.state;
if (state) {
if (parsedText.name && parsedText.name.indexOf(state) === -1) {
const mistake = fromLibpostal.state || fromLibpostal.country;
if (mistake) {
if (parsedText.name && parsedText.name.indexOf(mistake) === -1) {
parsedText.name = text; // parser is confused, search for full text
return;
}
Expand Down

0 comments on commit 68c34c2

Please sign in to comment.