Skip to content

Commit

Permalink
Remove leading slash from controller [#5651 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeltrix committed Sep 18, 2010
1 parent 7d54fba commit 301462c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/routing/mapper.rb
Expand Up @@ -128,7 +128,7 @@ def default_controller_and_action(to_shorthand=nil)
{ }
else
if to.is_a?(String)
controller, action = to.split('#')
controller, action = to.sub(%r{\A/}, '').split('#')
elsif to.is_a?(Symbol)
action = to.to_s
end
Expand Down
8 changes: 8 additions & 0 deletions actionpack/test/dispatch/routing_test.rb
Expand Up @@ -457,6 +457,8 @@ def self.matches?(request)
match '/cities', :to => 'countries#cities'
end

match '/feeds/:service', :to => '/api/feeds#show', :as => :feed

match '/countries/:country/(*other)', :to => redirect{ |params, req| params[:other] ? "/countries/all/#{params[:other]}" : '/countries/all' }

match '/:locale/*file.:format', :to => 'files#show', :file => /path\/to\/existing\/file/
Expand Down Expand Up @@ -2128,6 +2130,12 @@ def test_nested_resource_constraints
assert_raises(ActionController::RoutingError){ list_todo_path(:list_id => '2', :id => '1') }
end

def test_controller_has_leading_slash_removed
get '/feeds/twitter.xml'
assert_equal 'api/feeds#show', @response.body
assert_equal '/feeds/twitter.xml', feed_path(:service => 'twitter', :format => 'xml')
end

private
def with_test_routes
yield
Expand Down

0 comments on commit 301462c

Please sign in to comment.