You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The getCountryCode function currently performs a case-sensitive search for country names, which can limit its effectiveness. Users might input country names in various cases (e.g., "United States", "united states", "UNITED STATES"), expecting a valid response. However, the current implementation only matches exact cases.
I've looked into the past issues and I noticed that this was never reported before. I understand it's easy enough to implement my own search function, but since it comes bundled in the library I think it would be beneficial to all users.
It could also be interesting to think about implementing a fuzzy search, even though it might increase bundle size and there would be the need to mitigate performance issues.
I'm open to make a PR for this, if it makes sense to you 😄
The text was updated successfully, but these errors were encountered:
* Bump modules
* Update types and data for cases like #36 and #132
* Update comments in types.ts
* Update phone code for Kazakhstan to just `7` #134
* Case insensitive search in getCountryCode function #131
* Rebuild dist data
Use case for the feature
The
getCountryCode
function currently performs a case-sensitive search for country names, which can limit its effectiveness. Users might input country names in various cases (e.g., "United States", "united states", "UNITED STATES"), expecting a valid response. However, the current implementation only matches exact cases.I've looked into the past issues and I noticed that this was never reported before. I understand it's easy enough to implement my own search function, but since it comes bundled in the library I think it would be beneficial to all users.
Examples or links
This is the function in question:
A potential, quick solution could just be to compare both strings as lower case:
It could also be interesting to think about implementing a fuzzy search, even though it might increase bundle size and there would be the need to mitigate performance issues.
I'm open to make a PR for this, if it makes sense to you 😄
The text was updated successfully, but these errors were encountered: