wooorm / iso-3166

ISO 3166 (standard for country codes and codes for their subdivisions)
MIT License
79 stars 13 forks source link

Added shouldReplaceBr method #4

Closed mancku closed 1 year ago

mancku commented 1 year ago

Hi @wooorm

After taking a look at the Wikipedia page as you suggested in your comment I understood that the page is pretty consistent itself, so instead of modifying the page to adapt it to this code, I adapted the code so it can handle cases like the ones I mentioned in the issue.

I created a list of countries that have two names separated by a
(Spain is the only one that I know of, but as this is scrapping the Wikipedia, it might change in the future) and in those, replace the
element with the text -br-. Then just deleting the -br- and whatever is after that does the trick.

I know this is not the most elegant solution, but it's simple and easy to understand, read and maintain, I think.

Please, feel free to modify the code or just reject the PR if you don't think it should be done this way.

Thanks!

wooorm commented 1 year ago

Hi there! Thanks for your patience, funnily enough I was on holiday in Spain (ES-AN) ;)

Managed to investigate this today. I had a slightly different method in mind, which kinda does exactly the same as you, and found that it also fixed some other cases (see above linked commit). So went with that instead of an option while attributing you!

Thanks :)