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

Unable to properly parse country from UK phone number #343

Closed simplenotezy closed 5 years ago

simplenotezy commented 5 years ago

If I try to parse a UK number like so:

parsePhoneNumberFromString('+4412345678')

It is unable to provide me with a country key:

PhoneNumber {countryCallingCode: "44", nationalNumber: "12345678", number: "+4412345678", metadata: {…}}
countryCallingCode: "44"
metadata: {version: "1.7.24", country_calling_codes: {…}, countries: {…}}
nationalNumber: "12345678"
number: "+4412345678"
__proto__: Object

However, it works just fine with: parsePhoneNumberFromString('+4512345678')

See output:

PhoneNumber {countryCallingCode: "45", nationalNumber: "12345678", number: "+4512345678", metadata: {…}, country: "DK"}
country: "DK"
countryCallingCode: "45"
metadata: {version: "1.7.24", country_calling_codes: {…}, countries: {…}}
nationalNumber: "12345678"
number: "+4512345678"
__proto__: Object
catamphetamine commented 5 years ago

See the "bug reporting" section of the readme. Reopen if the issue persists after following the procedure.