Skip to content

Commit

Permalink
Merge pull request floere#508 from pedropaulo15/add-support-for-norfo…
Browse files Browse the repository at this point in the history
…lk-island

Adding support for Norfolk Island
  • Loading branch information
floere authored May 6, 2023
2 parents 7e50af9 + 03e5fce commit c0b07d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/phony/countries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,14 @@
)

country '671', todo # Spare code
country '672', todo # Australian External Territories

# Australian External Territories https://en.wikipedia.org/wiki/Telephone_numbers_in_Norfolk_Island
# Norfolk Island
country '672',
fixed(1) >> split(2,3) |
match(/^(2\d\d\d\d).+$/) >> split(3) | # Fixed
match(/^(5\d\d\d\d).+$/) >> split(3) # Mobile

country '673', fixed(1) >> split(3, 3) # Brunei Darussalam https://www.wtng.info/wtng-673-bn.html
country '674', none >> split(3, 4) # Nauru (Republic of) https://www.wtng.info/wtng-674-nr.html

Expand Down
4 changes: 4 additions & 0 deletions spec/lib/phony/countries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,10 @@ def self.it_splits number, expected
it_splits '31222123456', ['31', '222', '123', '456']
it_splits '3197012345678', ['31', '970', '1234', '5678'] # machine-to-machine
end
describe 'Norfolk Island' do
it_splits '672321234', ['672', '3', '21', '234'] # fixed
it_splits '672351234', ['672', '3', '51', '234'] # mobile
end
describe 'Norway' do
it_splits '4721234567', ['47',false,'21','23','45','67']
it_splits '4731234567', ['47',false,'31','23','45','67']
Expand Down

0 comments on commit c0b07d3

Please sign in to comment.