From 453ed1539500f3dc9f704bb0933f50cc42bbe46a Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 28 Jun 2005 21:18:04 +0000 Subject: Routes fail with leading slash #1540 [Nicholas Seckar] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1555 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_controller/routing.rb | 1 + actionpack/test/controller/routing_test.rb | 5 +++++ 3 files changed, 8 insertions(+) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index f124a935c0..b3e1425843 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Routes fail with leading slash #1540 [Nicholas Seckar] + * Added support for upload progress indicators in Apache and lighttpd 1.4.x (won't work in WEBrick or lighttpd 1.3.x) #1475 [Sean Treadway] See http://sean.treadway.info/files/howto-upload-progress-2.mov for example. diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 998faf356f..5499cd2545 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -320,6 +320,7 @@ module ActionController def initialize_components(path) path = path.split('/') if path.is_a? String + path.shift if path.first.blank? self.components = path.collect {|str| Component.new str} end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 60481ec9d0..d7b10f69d9 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -574,6 +574,11 @@ class RouteSetTests < Test::Unit::TestCase assert_equal ['admin/user/show', {}], rs.generate({:action => 'show'}, {:controller => 'admin/user', :action => 'list', :id => '10'}) assert_equal ['admin/user/list/10', {}], rs.generate({}, {:controller => 'admin/user', :action => 'list', :id => '10'}) end + + def test_ignores_leading_slash + @rs.draw {|m| m.connect '/:controller/:action/:id'} + test_default_setup + end def test_time_recognition n = 10000 -- cgit v1.2.3