diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-06 15:22:32 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-06 15:22:32 +0000 |
commit | 480150e5fb73f1a6a23bb08fdf9a537ccbd6f60d (patch) | |
tree | 3e9e3065c6294a3d7dace64049d6207995bdafce /actionpack | |
parent | 642713358400c186a41856c5464a232a20d0ebd1 (diff) | |
download | rails-480150e5fb73f1a6a23bb08fdf9a537ccbd6f60d.tar.gz rails-480150e5fb73f1a6a23bb08fdf9a537ccbd6f60d.tar.bz2 rails-480150e5fb73f1a6a23bb08fdf9a537ccbd6f60d.zip |
Fixed autolinking to work better in more cases #1013 [Jamis Buck]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1099 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/helpers/text_helper.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 043e1dc305..5fcb8a250f 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -157,7 +157,14 @@ module ActionView # Turns all urls into clickable links. def auto_link_urls(text) - text.gsub(/([^=><!:'"\/]|^)((http[s]?:\/\/)|(www\.))(\S+\b\/?)([[:punct:]]*)(\s|$)/, '\1<a href="\3\4\5">\3\4\5</a>\6\7') + text.gsub(/(<\w+.*?>|[^=!:'"\/]|^)((?:http[s]?:\/\/)|(?:www\.))([^\s<]+\/?)([[:punct:]]|\s|<|$)/) do + all, a, b, c, d = $&, $1, $2, $3, $4 + if a =~ /<a\s/i # don't replace URL's that are already linked + all + else + %(#{a}<a href="#{b=="www."?"http://www.":b}#{c}">#{b}#{c}</a>#{d}) + end + end end # Turns all email addresses into clickable links. |