From 5e3364ef452d8b3d6e1b4eacfd9c8939be392c29 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Wed, 14 Sep 2005 12:07:05 +0000 Subject: More auto-link fixes (to include query strings in autolinked text) git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2241 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/text_helper.rb | 2 +- actionpack/test/template/text_helper_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 7b883a8b27..bc753262f2 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -290,7 +290,7 @@ module ActionView (?:www\.) # www.* ) ( - ([\w]+[\/.-]?)* # url segment + ([\w]+[=?&\/.-]?)* # url segment \w+[\/]? # url tail (?:\#\w*)? # trailing anchor ) diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index f56207f1f1..383e9f64f8 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -95,6 +95,8 @@ class TextHelperTest < Test::Unit::TestCase link2_result = %{#{link2_raw}} link3_raw = 'http://manuals.ruby-on-rails.com/read/chapter.need_a-period/103#page281' link3_result = %{#{link3_raw}} + link4_raw = 'http://foo.example.com/controller/action?parm=value&p2=v2#anchor123' + link4_result = %{#{link4_raw}} assert_equal %(hello #{email_result}), auto_link("hello #{email_raw}", :email_addresses) assert_equal %(Go to #{link_result}), auto_link("Go to #{link_raw}", :urls) @@ -117,6 +119,8 @@ class TextHelperTest < Test::Unit::TestCase assert_equal %(

#{link3_result} Link

), auto_link("

#{link3_raw} Link

") assert_equal %(Go to #{link3_result}.), auto_link(%(Go to #{link3_raw}.)) assert_equal %(

Go to #{link3_result}. seriously, #{link3_result}? i think I'll say hello to #{email_result}. instead.

), auto_link(%(

Go to #{link3_raw}. seriously, #{link3_raw}? i think I'll say hello to #{email_raw}. instead.

)) + assert_equal %(

Link #{link4_result}

), auto_link("

Link #{link4_raw}

") + assert_equal %(

#{link4_result} Link

), auto_link("

#{link4_raw} Link

") end def test_auto_link_at_eol -- cgit v1.2.3