Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #16 from PugglePay/master

Do not normalize an implausible phone (by checking Phony.plausible?(number)).
  • Loading branch information...
commit 8796c35df7e3e42eedd4e56d622b3bc1c9957db3 2 parents b70c531 + 1f30058
@joost authored
Showing with 5 additions and 1 deletion.
  1. +1 −1  lib/phony_rails.rb
  2. +4 −0 spec/lib/phony_rails_spec.rb
View
2  lib/phony_rails.rb
@@ -25,7 +25,7 @@ def self.normalize_number(number, options = {})
# Add country_number if missing
number = "#{country_number}#{number}" if not number =~ /^(00|\+)?#{country_number}/
end
- number = Phony.normalize(number)
+ number = Phony.normalize(number) if Phony.plausible?(number)
return number.to_s
rescue
number # If all goes wrong .. we still return the original input.
View
4 spec/lib/phony_rails_spec.rb
@@ -34,6 +34,10 @@
PhonyRails.normalize_number('+31-70-4157134', :country_code => 'NL').should eql('31704157134')
PhonyRails.normalize_number('0323-2269497', :country_code => 'BE').should eql('323232269497')
end
+
+ it "should not normalize an implausible number" do
+ PhonyRails.normalize_number('01').should eql('01')
+ end
end
describe 'defining ActiveRecord#phony_normalized_method' do
Please sign in to comment.
Something went wrong with that request. Please try again.