You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We were running into an issue with an Italian number that had an area code that was matching the country code.
This is an example of the problem phone no: +39 393 2612345
We would pass this into phonie and get back an incorrect phone number:
Phonie::Phone.parse("3932612345", country_code: "39").format("00%c%a%n") => "003932612345"
Phonie as it stands does a full number regex pattern match when it is attempting to parse, which checks for country code, area code and the number.
Full Number Match
Regexp.new("^[+]?(#{country_code})(#{area_code})(#{local_number_format})$")
The issue is 393 is the area code which contains the same numbers as the country code of 39.
326 is also a valid area code, phonie thinks this number is alright since it's still valid regex.
What I had proposed on doing was rewriting the parse function of parser class to read the area code first if the country code was present.
An issue with this became present in the cn_test.rb spec however as the country code was both present in the phone number and within the country_code variable.
We were running into an issue with an Italian number that had an area code that was matching the country code.
This is an example of the problem phone no: +39 393 2612345
We would pass this into phonie and get back an incorrect phone number:
Phonie::Phone.parse("3932612345", country_code: "39").format("00%c%a%n") => "003932612345"
Phonie as it stands does a full number regex pattern match when it is attempting to parse, which checks for country code, area code and the number.
Full Number Match
Regexp.new("^[+]?(#{country_code})(#{area_code})(#{local_number_format})$")
The issue is 393 is the area code which contains the same numbers as the country code of 39.
326 is also a valid area code, phonie thinks this number is alright since it's still valid regex.
What I had proposed on doing was rewriting the parse function of parser class to read the area code first if the country code was present.
An issue with this became present in the cn_test.rb spec however as the country code was both present in the phone number and within the country_code variable.
https://github.com/wmoxam/phonie/blob/master/lib/phonie/parser.rb#L39
What I wanted to do:
Any help on this would be appreciated!
The text was updated successfully, but these errors were encountered: