Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default_country_number appending repeatedly #25

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

Fix default_country_number appending repeatedly #25

joost opened this issue May 7, 2013 · 0 comments

Comments

@joost
Copy link
Owner

joost commented May 7, 2013

See mjc@fd2abb5

joost pushed a commit that referenced this issue May 7, 2013
@joost joost closed this as completed May 7, 2013
joost referenced this issue in mjc/phony_rails May 7, 2013
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant