daddyz / phonelib

Ruby gem for phone validation and formatting using google libphonenumber library data
MIT License
1.04k stars 130 forks source link

Incorrect national formatting for Canadian numbers #240

Closed philippevezina closed 2 years ago

philippevezina commented 2 years ago

Formatting for Canadian phone numbers is incorrect:

Phonelib.parse('418 928 3648', 'CA').national
=> "418 928 3648"

What should be returned: (418) 928-3648. Here is the proof of concept with libphonenumber's sandbox: http://libphonenumber.appspot.com/phonenumberparser?number=4189283648&country=CA&geocodingLocale=en-US

I can't say whether this is simply because it would have been fixed recently in libphonenumber and that phonelib's data is outdated or if it is rather a bug with phonelib.

Documentation on how to update the data could be appropriate to include in the README or Wiki.

philippevezina commented 2 years ago

I see that the data has been updated since and the problem is still there. I would be inclined to say the problem is in the gem.

daddyz commented 2 years ago

@philippevezina thanks for reporting. I found a bug in formatting rules. Fixed in version 0.6.57

Phonelib.parse('418 928 3648', 'CA').national # => "(418) 928-3648"
philippevezina commented 2 years ago

That's great! Thank you very much!