catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.8k stars 216 forks source link

Wrong value for phone that's start from +1 8001 #412

Closed VasylenkoStanislav closed 3 years ago

VasylenkoStanislav commented 3 years ago

Steps to reproduce

parsePhoneNumberFromString('+18001646460');

Observed result

This expression return country set to Dominicana countryCallingCode: "1" nationalNumber: "8001646460" number: "+18001646460" country: "DO"

Expected result country: "US"

catamphetamine commented 3 years ago

You haven't provided a link to Google's demo https://github.com/catamphetamine/libphonenumber-js#bug-reporting

gtoroptsev commented 3 years ago

I also encountered same issue, the solution is to use max metadata sets instead of min, you can read about it in docs (tbh, at first I thought that "min" postfix in CDN's url is minified version of script):

https://github.com/catamphetamine/libphonenumber-js#min-vs-max-vs-mobile-vs-core

catamphetamine commented 3 years ago

@gtoroptsev Metadata selection shouldn't influence country detection. I'll check.

catamphetamine commented 3 years ago

@gtoroptsev Or provide an exact example

catamphetamine commented 3 years ago

The originally reported number is recognized as DOminican by Google's library, so there's no bug. https://libphonenumber.appspot.com/phonenumberparser?number=%2B18001646460&country=RU