Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make searches by name (getAlpha2Code, getSimpleAlpha2Code, getAlpha3Code, getSimpleAlpha3Code) fail when more than one result is found #278

Open
iamleeg opened this issue Jan 31, 2022 · 3 comments

Comments

@iamleeg
Copy link
Contributor

iamleeg commented Jan 31, 2022

Both the Democratic Republic of the Congo and the Republic of the Congo have "Congo" as a possible name in the English data. While this reflects reality, and both countries are colloquially called "The Congo" or "Congo", the library will always return the first one it encounters. It should probably return both or neither and make the developer do more work, otherwise it's just going to erase one of the two countries in my application.

@michaelwittig
Copy link
Owner

Hi! Are you referring to the change made in #276 ? According to this logic, the official name must be first, the alias second. The entry for CD should be ["Congo", "Democratic Republic of the Congo"].
Let me know if that addresses your issue.

@michaelwittig michaelwittig self-assigned this Jan 31, 2022
@iamleeg
Copy link
Contributor Author

iamleeg commented Feb 1, 2022

I mean that this line:

console.log(countries.getAlpha2Code('Congo', 'en'));

logs CG when it could also be CD. Switching which one it returns wouldn't help, because the point is that there isn't a single country with the name "Congo". Returning ['CD', 'CG'] makes sense, throwing makes sense, I do not think returning one or the other is a good idea.

@michaelwittig michaelwittig changed the title Congo is listed twice make searches by name (getAlpha2Code, getSimpleAlpha2Code, getAlpha3Code, getSimpleAlpha3Code) fail when more than one result is found Feb 1, 2022
@michaelwittig michaelwittig removed their assignment Feb 1, 2022
@michaelwittig
Copy link
Owner

I get your point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants