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.81k stars 216 forks source link

how to detect the country without receiving country code? #361

Closed happyChappy13g closed 5 years ago

happyChappy13g commented 5 years ago

hello I'm getting all contacts from the user's phone number and send them to the backend. some of them are formatted internationally like +1 865 566 2364 or +98 902 7575 765. but many of them are just formatted nationally like (213) 373-4253 or 0902 7575 065. how can I automatically detect the country code from the second ones and format them internationally so I can store them in DB with the same format?

catamphetamine commented 5 years ago

how can I automatically detect the country code from the second ones

While theoretically someone could write a software that would detect a country by national phone number format, there's no such feature in this library (and there won't be).