Prevent exceptions with invalid URIs
This commit is contained in:
parent
cc753c0882
commit
13c397fe73
|
@ -2,6 +2,7 @@ module SharedMarkers
|
||||||
include ActionView::Helpers::TagHelper
|
include ActionView::Helpers::TagHelper
|
||||||
|
|
||||||
def autolink(link, _link_type)
|
def autolink(link, _link_type)
|
||||||
|
begin
|
||||||
href = if ALLOWED_HOSTS_IN_MARKDOWN.include?(URI(link).host)
|
href = if ALLOWED_HOSTS_IN_MARKDOWN.include?(URI(link).host)
|
||||||
link
|
link
|
||||||
else
|
else
|
||||||
|
@ -9,5 +10,8 @@ module SharedMarkers
|
||||||
end
|
end
|
||||||
|
|
||||||
content_tag(:a, link, href: href, target: "_blank", rel: "nofollow")
|
content_tag(:a, link, href: href, target: "_blank", rel: "nofollow")
|
||||||
|
rescue
|
||||||
|
link
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue