Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Fix numbers which start with country codes. #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/global_phone/territory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def strip_prefixes(string)
string_without_prefix = string.sub(national_prefix_for_parsing, transform_rule)
elsif starts_with_national_prefix?(string)
string_without_prefix = string[national_prefix.length..-1]
elsif starts_with_country_code?(string)
elsif !possible?(string) && starts_with_country_code?(string)
string_without_prefix = string[country_code.length..-1]
end

Expand Down
5 changes: 5 additions & 0 deletions test/context_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class ContextTest < TestCase
:country_code => "44", :national_string => "2070313000"
end

test "parsing national number for given territory with leading country code" do
assert_parses "3914172422", :with_territory => :it,
:country_code => "39", :national_string => "3914172422"
end

test "parsing international number with prefix" do
assert_parses "00 1 3125551212", :with_territory => :gb,
:country_code => "1", :national_string => "3125551212"
Expand Down