summaryrefslogtreecommitdiff
path: root/app/helpers/external_link_helper.rb
diff options
context:
space:
mode:
authorjakeburden <jburden@gitlab.com>2019-08-30 18:16:39 -0400
committerjakeburden <jburden@gitlab.com>2019-09-03 16:40:38 -0400
commit90dc19e9f0be8ac530b5e5e042791143ce0ba0ce (patch)
treed29578ef53dea5faefb39eaddf7157d6a664e417 /app/helpers/external_link_helper.rb
parent5c25a757dcdeb9aae38744ed8b43832ff51e3dcb (diff)
downloadgitlab-ce-90dc19e9f0be8ac530b5e5e042791143ce0ba0ce.tar.gz
Create and use external_link helper
Creates a helper method that takes body text and a url. The output is a external link with icon. It contains the noopenner noreferrer attributes for security. Usage: external_link(domain.title, domain.url) Add rspec test for ExternalLinkHelper Add changelog for MR 32130
Diffstat (limited to 'app/helpers/external_link_helper.rb')
-rw-r--r--app/helpers/external_link_helper.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/helpers/external_link_helper.rb b/app/helpers/external_link_helper.rb
new file mode 100644
index 00000000000..fe908b3ae1c
--- /dev/null
+++ b/app/helpers/external_link_helper.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module ExternalLinkHelper
+ def external_link(body, url)
+ link_to url, target: '_blank', rel: 'noopener noreferrer' do
+ "#{body} #{icon('external-link')}".html_safe
+ end
+ end
+end