mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make auto_link handle nil by returning quickly if blank?
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3359 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
b5ba377b78
commit
63c822afb2
3 changed files with 5 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Make auto_link handle nil by returning quickly if blank? [Scott Barron]
|
||||
|
||||
* Make auto_link match urls with a port number specified. [Marcel Molina Jr.]
|
||||
|
||||
* Added support for toggling visual effects to ScriptaculousHelper::visual_effect, #3323. [Thomas Fuchs]
|
||||
|
|
|
@ -142,6 +142,7 @@ module ActionView
|
|||
# truncate(text, 15)
|
||||
# end
|
||||
def auto_link(text, link = :all, href_options = {}, &block)
|
||||
return '' if text.blank?
|
||||
case link
|
||||
when :all then auto_link_urls(auto_link_email_addresses(text, &block), href_options, &block)
|
||||
when :email_addresses then auto_link_email_addresses(text, &block)
|
||||
|
|
|
@ -155,6 +155,8 @@ class TextHelperTest < Test::Unit::TestCase
|
|||
assert_equal %(<p>Link #{link4_result}</p>), auto_link("<p>Link #{link4_raw}</p>")
|
||||
assert_equal %(<p>#{link4_result} Link</p>), auto_link("<p>#{link4_raw} Link</p>")
|
||||
assert_equal %(<p>#{link5_result} Link</p>), auto_link("<p>#{link5_raw} Link</p>")
|
||||
assert_equal '', auto_link(nil)
|
||||
assert_equal '', auto_link('')
|
||||
end
|
||||
|
||||
def test_auto_link_at_eol
|
||||
|
|
Loading…
Reference in a new issue