Retrospring/app/services/shared_markers.rb

17 lines
387 B
Ruby
Raw Normal View History

module SharedMarkers
include ActionView::Helpers::TagHelper
def autolink(link, _link_type)
2022-01-02 10:15:50 -08:00
begin
href = if ALLOWED_HOSTS_IN_MARKDOWN.include?(URI(link).host)
link
else
linkfilter_path(url: link)
end
content_tag(:a, link, href: href, target: "_blank", rel: "nofollow")
rescue
link
end
end
end