mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-02-13 21:33:20 +01:00
Prevent exceptions with invalid URIs
This commit is contained in:
parent
cc753c0882
commit
13c397fe73
1 changed files with 11 additions and 7 deletions
|
@ -2,12 +2,16 @@ module SharedMarkers
|
|||
include ActionView::Helpers::TagHelper
|
||||
|
||||
def autolink(link, _link_type)
|
||||
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")
|
||||
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
|
Loading…
Reference in a new issue