Skip to content

Commit

Permalink
fixed issue #303
Browse files Browse the repository at this point in the history
  • Loading branch information
daddyz committed Jul 17, 2024
1 parent 318c4f5 commit e88403e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/phonelib/phone_analyzer_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def decorate_analyze_result(result)
result
else
matched_countries = country_or_default_country(nil) & result.keys
matched_countries = result.keys.take(1) if matched_countries.size == 0
result = result.keep_if {|k, _v| matched_countries.include?(k) } if matched_countries
Hash[result.take(1)]
end
Expand Down
14 changes: 14 additions & 0 deletions spec/phonelib_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,20 @@
end
end

context 'issue #303' do
it 'should parse possible numbers if countries array passed' do
p1 = Phonelib.parse('1212 111 1111', :us)
expect(p1.valid?).to be(false)
expect(p1.possible?).to be(true)

p2 = Phonelib.parse('1212 111 1111', %w(US CA))
expect(p2.valid?).to be(false)
expect(p2.possible?).to be(true)

expect(p1.e164).to eq(p2.e164)
end
end

context 'example numbers' do
it 'are valid' do
data_file = File.dirname(__FILE__) + '/../data/phone_data.dat'
Expand Down

0 comments on commit e88403e

Please sign in to comment.