Skip to content

Commit

Permalink
fixed issue #325 and #326
Browse files Browse the repository at this point in the history
  • Loading branch information
daddyz committed Dec 16, 2024
1 parent 4915b06 commit 5041e52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/phonelib/phone_analyzer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def detect_and_parse(phone, country)
countries_data.each_with_object({}) do |data, result|
key = data[:id]
parsed = parse_single_country(phone, data)
parsed = parse_single_country(with_replaced_national_prefix(phone, data), data) unless parsed && parsed[key] && parsed[key][:valid].size > 0
if (!Phonelib.strict_double_prefix_check || key == country) && double_prefix_allowed?(data, phone, parsed && parsed[key])
parsed2 = parse_single_country(changed_dp_phone(key, phone), data)
parsed = parsed2 if parsed2 && parsed2[key] && parsed2[key][:valid].size > 0
Expand Down
9 changes: 9 additions & 0 deletions spec/phonelib_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,15 @@
end
end

context 'issue #325' do
it 'should change number according to new format' do
p = Phonelib.parse("540111557447700")
expect(p.country).to eq('AR')
expect(p.e164).to eq('+5491157447700')
expect(p.valid?).to be(true)
end
end

def phone_assertions(phone, type, country, msg)
expect(phone.valid?).to be(true), "#{msg} not valid"
expect(phone.invalid?).to be(false), "#{msg} not valid"
Expand Down

0 comments on commit 5041e52

Please sign in to comment.