mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-02-13 21:33:20 +01:00
Refactor SharedMarkers::autolink
to use content_tag
This commit is contained in:
parent
bc65b42b02
commit
c28ecafa80
1 changed files with 9 additions and 5 deletions
|
@ -1,9 +1,13 @@
|
||||||
module SharedMarkers
|
module SharedMarkers
|
||||||
|
include ActionView::Helpers::TagHelper
|
||||||
|
|
||||||
def autolink(link, _link_type)
|
def autolink(link, _link_type)
|
||||||
if ALLOWED_HOSTS.include? URI(link).host
|
href = if ALLOWED_HOSTS_IN_MARKDOWN.include?(URI(link).host)
|
||||||
return "<a href=\"#{link}\" target=\"_blank\">#{link}</a>"
|
link
|
||||||
|
else
|
||||||
|
linkfilter_path(url: link)
|
||||||
end
|
end
|
||||||
|
|
||||||
"<a href=\"#{linkfilter_path(url: link)}\" target=\"_blank\">#{link}</a>"
|
content_tag(:a, link, href: href, target: "_blank", rel: "nofollow")
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue