Skip to content
This repository
Browse code

Respect :spaces when removing trailing space(s)

  • Loading branch information...
commit d0d9a835e7dba031b87d006f9e4ed5d627bbc6e4 1 parent 3851473
Ralph Churchill authored July 15, 2011
2  lib/phony/country_codes.rb
@@ -46,7 +46,7 @@ def format_cc_ndc_local format, space, cc, ndc, *parts
46 46
       cc_ndc = format_cc_ndc(format, space, cc, ndc)
47 47
       local  = \
48 48
         if parts.empty?
49  
-          cc_ndc = cc_ndc.slice(0...cc_ndc.size-1)
  49
+          cc_ndc = cc_ndc.slice(0...cc_ndc.rindex(space.to_s))
50 50
           EMPTY_STRING
51 51
         else
52 52
           format_local(space, parts) unless parts.empty?
3  spec/lib/phony_spec.rb
@@ -137,6 +137,9 @@
137 137
         it 'should format as a single block, respecting custom spaces' do
138 138
           Phony.format('8801819372205', :spaces => :-).should == '+880-1819372205'
139 139
         end
  140
+        it 'should format as a single block, even without spaces' do
  141
+          Phony.format('8801819372205', :spaces => '').should == '+8801819372205'
  142
+        end
140 143
       end
141 144
     end
142 145
     describe "national" do

0 notes on commit d0d9a83

Please sign in to comment.
Something went wrong with that request. Please try again.