diff --git a/lib/phonelib/phone_analyzer.rb b/lib/phonelib/phone_analyzer.rb index bead660..be424af 100644 --- a/lib/phonelib/phone_analyzer.rb +++ b/lib/phonelib/phone_analyzer.rb @@ -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 diff --git a/spec/phonelib_spec.rb b/spec/phonelib_spec.rb index 43e9367..792c91e 100644 --- a/spec/phonelib_spec.rb +++ b/spec/phonelib_spec.rb @@ -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"