debian-mirror-gitlab/app/helpers/external_link_helper.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

13 lines
460 B
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
module ExternalLinkHelper
2021-09-30 23:02:18 +05:30
include ActionView::Helpers::TextHelper
2019-12-04 20:38:33 +05:30
def external_link(body, url, options = {})
2021-09-30 23:02:18 +05:30
link = link_to url, { target: '_blank', rel: 'noopener noreferrer' }.merge(options) do
2022-06-21 17:19:12 +05:30
"#{body}#{sprite_icon('external-link', css_class: 'gl-ml-2')}".html_safe
2019-12-04 20:38:33 +05:30
end
2021-09-30 23:02:18 +05:30
sanitize(link, tags: %w(a svg use), attributes: %w(target rel data-testid class href).concat(options.stringify_keys.keys))
2019-12-04 20:38:33 +05:30
end
end