daddyz/phonelib

international parsing fails on 8 digit indian numbers

Opened this issue · 2 comments

similar to issue 168, 8 digit indian phone numbers do not parse properly, whereas 10 digit indian phone numbers parse correctly. Please note that the country code is prepended twice on 8 digit indian phone numbers,

`2.3.6 :021 > Phonelib.parse('911234567890').international

=> "+91 1234 567 890"

2.3.6 :022 > Phonelib.parse('9112345678').international

=> "+91 91123 45678" `

In rails, this behavior can be fixed by adding Phonelib.strict_double_prefix_check = true to config/initializers/phonelib.rb

@chiefjuss number 9112345678 is not valid by google's regex.

Phonelib.parse('+9112345678').valid? # => false

Since number is not valid, for countries with option to have double country prefix, library tries to add additional country prefix and reparse, and in case it's valid, the new number will be returned. So your suggestion is not good. You need to open an issue in original google lib. You can check that it fails here