diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index b710157f51272c4408c6ccf64a1cf68a27c99db2..669a2854247410d079039e892ae6982aaa2cf772 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -454,7 +454,7 @@ def set_cycle(name, cycle_object)
( # leading text
<\w+.*?>| # leading HTML tag, or
[^=!:'"/]| # leading punctuation, or
- | # nothing
+ ^ # beginning of line
)
(
(?:https?://)| # protocol spec, or
@@ -468,7 +468,7 @@ def set_cycle(name, cycle_object)
(?:\?[\w\+@%&=.;-]+)? # query string
(?:\#[\w\-]*)? # trailing anchor
)
- ([[:punct:]]|\s|<|$) # trailing text
+ ([[:punct:]]|<|$|) # trailing text
}x unless const_defined?(:AUTO_LINK_RE)
# Turns all urls into clickable links. If a block is given, each url
diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb
index 36c939f761c6cf95c4f5361f5ef00986631c1f29..62cdca03d176fea28b0f17f33f72c478868d88e2 100644
--- a/actionpack/test/template/text_helper_test.rb
+++ b/actionpack/test/template/text_helper_test.rb
@@ -264,6 +264,7 @@ def test_auto_linking
assert_equal '', auto_link(nil)
assert_equal '', auto_link('')
assert_equal "#{link_result} #{link_result} #{link_result}", auto_link("#{link_raw} #{link_raw} #{link_raw}")
+ assert_equal 'Ruby On Rails', auto_link('Ruby On Rails')
end
def test_auto_link_at_eol