global_phone icon indicating copy to clipboard operation
global_phone copied to clipboard

doesn't parse numbers with extensions?

Open ericcj opened this issue 12 years ago • 6 comments

2.0.0-p247 :013 > GlobalPhone.parse('(201) 482-4764x1234') => nil 2.0.0-p247 :014 > GlobalPhone.parse('+12014824764x1234') => nil 2.0.0-p247 :015 > GlobalPhone.parse('+12014824764 ext. 1234') => nil

ericcj avatar Nov 01 '13 15:11 ericcj

This would be a nice feature.

trliner avatar Dec 16 '13 22:12 trliner

truth

hoguej avatar Sep 11 '14 06:09 hoguej

I know this was a long time ago, but I'm not sure what feature you're requesting. You want numbers with extensions to be parsed? Or you think that parsing them should return an error and not nil? If you're still interested in this feature can you clarify it and I'll reopen this issue. Thanks!

eileencodes avatar Oct 04 '15 16:10 eileencodes

I think the requested feature was to start parsing numbers with extensions. Right now, I'm using a regex to grab the part of the number in front of the extension before parsing it, but it would be nice if global_phone did that internally.

# In order to allow for extensions, we have to split on the first character that's not  
# a digit, white space character, parenthesis, period, plus sign, or minus sign, then 
# parse the first part.
phone_string = '(201) 482-4764x1234'
number_part = phone_string.split(/[^\d\s\(\)\.\-\+]/).first
parsed_number = GlobalPhone.parse(number_part)

trliner avatar Oct 05 '15 23:10 trliner

Thanks @trliner, I better understand the issue now. If anyone is interested in a PR that would be great. I'm not sure when I'll get around to implementing this, but I'll reopen.

eileencodes avatar Oct 06 '15 11:10 eileencodes

Strike this, just realized this is a re-implementation and not a wrapper.

~~Out of curiosity, why is this a problem with GlobalPhone? Shouldn't GlobalPhone be passing off to libphonenumber, which does support using extensions? I have run into the same issue, where GlobalPhone doesn't parse the number when an extension is present.~~

theblang avatar Sep 06 '16 17:09 theblang