Files
nairobi/app/helpers/text_with_links_helper.rb
Javi Martín aeff8a0f31 Don't open auto links in a new tab
Just like we aren't opening any external links in a new tab, only, in
this case, we don't even know whether these links are internal or
external.
2023-10-24 16:41:03 +02:00

20 lines
517 B
Ruby

module TextWithLinksHelper
def sanitize_and_auto_link(text)
return unless text
sanitized = sanitize(text, tags: [], attributes: [])
auto_link_already_sanitized_html(sanitized)
end
def auto_link_already_sanitized_html(html)
return if html.nil?
raise "Could not add links because the content is not safe" unless html.html_safe?
raw Rinku.auto_link(html, :all, 'rel="nofollow"')
end
def simple_format_no_tags_no_sanitize(html)
simple_format(html, {}, sanitize: false)
end
end