2019-08-30 18:16:39 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module ExternalLinkHelper
|
2021-09-30 14:11:31 -04:00
|
|
|
include ActionView::Helpers::TextHelper
|
|
|
|
|
2019-09-03 17:26:39 -04:00
|
|
|
def external_link(body, url, options = {})
|
2021-09-30 14:11:31 -04:00
|
|
|
link = link_to url, { target: '_blank', rel: 'noopener noreferrer' }.merge(options) do
|
2021-01-28 16:09:04 -05:00
|
|
|
"#{body}#{sprite_icon('external-link', css_class: 'gl-ml-1')}".html_safe
|
2019-08-30 18:16:39 -04:00
|
|
|
end
|
2021-09-30 14:11:31 -04:00
|
|
|
sanitize(link, tags: %w(a svg use), attributes: %w(target rel data-testid class href).concat(options.stringify_keys.keys))
|
2019-08-30 18:16:39 -04:00
|
|
|
end
|
|
|
|
end
|