Fix default_country_number appending repeatedly #25

Closed
joost opened this Issue May 7, 2013 · 0 comments

1 participant

@joost
Owner
@joost joost closed this May 7, 2013
@joost joost referenced this issue in mjc/phony_rails May 7, 2013
@mjc mjc Fix default_country_number appending repeatedly
The regex for appending default country number doesn't correctly check if the actual country code is already there.
```
default_country_number = 1
number = '9545551212'
number = "#{default_country_number}#{number}" if not number =~ /^(00|\+)/
=> "19545551212"

number = "19545551212"
number = "#{default_country_number}#{number}" if not number =~ /^(00|\+)/
=> "119545551212"
```

etc.

Fixed:
```
default_country_number = 1
number = '9545551212'
number = "#{default_country_number}#{number}" if not number =~ /^(00|\+)?#{default_country_number}/
=> "19545551212"
number = "#{default_country_number}#{number}" if not number =~ /^(00|\+)?#{default_country_number}/
=> "19545551212"
```

Sponsored-by: CentroNet Marketing
fd2abb5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment