jordanhudgens / phone_parser

MIT License
1 stars 0 forks source link

Handling Country Codes #1

Open lihtaes opened 7 years ago

lihtaes commented 7 years ago

A number is parsed regardless of country code, but the parser leaves the country code if there, and keeps the number as is if it is not there:

1(555) 555-5555 => 15555555555 (555)555-5555 => 5555555555

This can create an inconsistency when dealing with services such as Twilio which always include the country code.

Not sure what's better, add a country code if it isn't there, or remove it if it is, but having a consistent output would be ideal!!

Thanks for doing this!

jordanhudgens commented 7 years ago

@lihtaes I just pushed version 0.2.0, it now provides support for default country codes and by default it's set to 1 for US based numbers. The specs have the updated expectations, here are a few examples:

PhoneParser.parse('555-555-5555') # => '15555555555'
PhoneParser.parse('555-555-5555', country_code: '379') # => '3795555555555'