Skip to content

Commit

Permalink
Allow routes with a trailing slash to be recognized
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#2039 state:committed]
  • Loading branch information
Mike Gunderloy authored and NZKoz committed Mar 4, 2009
1 parent 9b1b88f commit ce56c5d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/routing/segments.rb
Expand Up @@ -318,7 +318,7 @@ def interpolation_chunk
end

def regexp_chunk
'(\.[^/?\.]+)?'
'/|(\.[^/?\.]+)?'
end

def to_s
Expand Down
12 changes: 10 additions & 2 deletions actionpack/test/controller/resources_test.rb
Expand Up @@ -750,9 +750,17 @@ def test_nested_resources_in_nested_namespace
end

def test_with_path_segment
with_restful_routing :messages, :as => 'reviews' do
assert_simply_restful_for :messages, :as => 'reviews'
with_restful_routing :messages do
assert_simply_restful_for :messages
assert_recognizes({:controller => "messages", :action => "index"}, "/messages")
assert_recognizes({:controller => "messages", :action => "index"}, "/messages/")
end

with_restful_routing :messages, :as => 'reviews' do
assert_simply_restful_for :messages, :as => 'reviews'
assert_recognizes({:controller => "messages", :action => "index"}, "/reviews")
assert_recognizes({:controller => "messages", :action => "index"}, "/reviews/")
end
end

def test_multiple_with_path_segment_and_controller
Expand Down

7 comments on commit ce56c5d

@ariejan
Copy link

@ariejan ariejan commented on ce56c5d Mar 4, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that previously routes with a trailing slash were not recognized properly?

@wincent
Copy link
Contributor

@wincent wincent commented on ce56c5d Mar 4, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means that it worked up to and including 2.2.2, was broken in 2.3.0 RC1, and is now fixed again.

@mapmarkus
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean 2 different urls for the same resource?… I mean, It’s a bot going to index those urls as duplicated content?

@ariejan
Copy link

@ariejan ariejan commented on ce56c5d Mar 4, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Wincent: that’s what I meant ;-) But thanks for clarifying. This explains some weirdness I’ve been experiencing with a Rails Edge project.

@Yizzreel: Depends entirely on the bot. Technically the URLs point to one and identical resource, so the URLs should be treated as the same, yes.

@mapmarkus
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ariejan
I’ve been reading a bit about this concern in Google’s webmaster tools. There’s an article in the help section about duplicated content
I’ll put an important note in this article

Be consistent: Try to keep your internal linking consistent. For example, don’t link to http://www.example.com/page/ and http://www.example.com/page and http://www.example.com/page/index.htm

This mean that http://www.example.com/page/ and http://www.example.com/page are not the same url, therefore are not the same resource, therefore are duplicated content.

However, this problem would be important only if you include both url formats in your application, and link helpers will always generate ‘/’-less urls

@mapmarkus
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my previous comment, the paragrapth “Be consistent: …” is extracted from google help section (I tried to use textile ‘bq. ’ but it doesn’t work)

@nertzy
Copy link
Contributor

@nertzy nertzy commented on ce56c5d Mar 7, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you’re concerned about two URLs pointing to the same resource, consider using the new canonical URL meta tag:

http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html

Please sign in to comment.