diff --git a/src/lib/Iso3166.ts b/src/lib/Iso3166.ts index 3a8ca12..5584f93 100644 --- a/src/lib/Iso3166.ts +++ b/src/lib/Iso3166.ts @@ -37,6 +37,14 @@ export const guessCountry: (location: string) => Option.Option = flo subDivision => subDivision.country, ), ), + Option.orElse(() => + location.length === 2 + ? Option.map( + Array.findFirst(subDivisions, subDivision => subDivision.code === `US-${location}`), + subDivision => subDivision.country, + ) + : Option.none(), + ), Option.orElse(() => Option.map( Array.matchLeft( diff --git a/test/Iso3166.test.ts b/test/Iso3166.test.ts index 9cf041c..5dbd320 100644 --- a/test/Iso3166.test.ts +++ b/test/Iso3166.test.ts @@ -5,6 +5,8 @@ import * as _ from '../src/lib/Iso3166.js' describe('guessCountry', () => { test.for([ ['Algiers ( Algeria)', 'DZ'], + ['Athens', 'GR'], + ['Athens, GA', 'US'], ['Baylor College of Medicine, Houston, Texas', 'US'], ['Beijing University of Technology, Beijing 100124, PR China', 'CN'], ['Brasil', 'BR'],