diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-11-06 23:39:09 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-06 23:39:09 -0500 |
commit | a8590da4bb4a3d8222800704c82cbfe755b8594a (patch) | |
tree | cfb9909ef320f304c59bc36aedfc8779a61b8530 | |
parent | 2e585e4040854ab561465a2cce32a488355fe307 (diff) | |
parent | 0f28957edd6a9c281491c854b455180efc040a1c (diff) | |
download | rails-a8590da4bb4a3d8222800704c82cbfe755b8594a.tar.gz rails-a8590da4bb4a3d8222800704c82cbfe755b8594a.tar.bz2 rails-a8590da4bb4a3d8222800704c82cbfe755b8594a.zip |
Merge pull request #30997 from q-centrix/nofollow-change
Prevent extra string allocations when no 'rel' arg passed
-rw-r--r-- | actionview/lib/action_view/helpers/url_helper.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index efda549c0d..9900e0cd03 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -589,10 +589,14 @@ module ActionView end def add_method_to_attributes!(html_options, method) - if method && method.to_s.downcase != "get".freeze && html_options["rel".freeze] !~ /nofollow/ - html_options["rel".freeze] = "#{html_options["rel".freeze]} nofollow".lstrip + if method && method.to_s.downcase != "get" && html_options["rel"] !~ /nofollow/ + if html_options["rel"].blank? + html_options["rel"] = "nofollow" + else + html_options["rel"] = "#{html_options["rel"]} nofollow" + end end - html_options["data-method".freeze] = method + html_options["data-method"] = method end def token_tag(token = nil, form_options: {}) |