X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/4aceca44f976f4c30ad074752b7f426703e64d5c..cc06ce4c8fcc7cd686d1991c12bf3638247a6fae:/lib/rich_text.rb diff --git a/lib/rich_text.rb b/lib/rich_text.rb index d6df214d1..d9c799611 100644 --- a/lib/rich_text.rb +++ b/lib/rich_text.rb @@ -76,7 +76,13 @@ module RichText end def linkify(text, mode = :urls) - Rinku.auto_link(ERB::Util.html_escape(text), mode, tag_builder.tag_options(:rel => "nofollow noopener noreferrer")).html_safe + link_attr = tag_builder.tag_options(:rel => "nofollow noopener noreferrer") + Rinku.auto_link(ERB::Util.html_escape(text), mode, link_attr) do |url| + %r{^https?://([^/]*)(.*)$}.match(url) do |m| + "#{Settings.linkify_hosts_replacement}#{m[2]}" if Settings.linkify_hosts_replacement && + Settings.linkify_hosts&.include?(m[1]) + end || url + end.html_safe end end