Skip to content
Merged
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
4 changes: 4 additions & 0 deletions lib/phony/countries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@
match(/^(2\d)\d{8}$/) >> split(2, 3, 3) |
match(/^(800)\d{6}$/) >> split(3, 3) | # International 800 service where agreed
match(/^(800)\d{7}$/) >> split(3, 4) | # International 800 service where agreed
match(/^(508)\d{6}$/) >> split(3, 3) | # Toll-free 0508
match(/^(508)\d{7}$/) >> split(3, 4) | # Toll-free 0508
match(/^(900)\d{5}$/) >> split(3, 2) | # Premium rate 0900
match(/^(900)\d{6}$/) >> split(3, 3) | # Premium rate 0900
fixed(1) >> split(3, 4) # Rest

# Singapore (Republic of).
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 @@ -947,6 +947,10 @@ def self.it_splits(number, expected)
it_splits '6491234567', %w[64 9 123 4567]
it_splits '64800123123', %w[64 800 123 123]
it_splits '648001231234', %w[64 800 123 1234]
it_splits '64508123123', %w[64 508 123 123] # Toll-free 0508
it_splits '645081231234', %w[64 508 123 1234] # Toll-free 0508
it_splits '6490012345', %w[64 900 123 45] # Premium 0900 (5 digits)
it_splits '64900123456', %w[64 900 123 456] # Premium 0900 (6 digits)
end

describe 'Bhutan (Kingdom of)' do
Expand Down
Loading