truncate urls on display on post replacements page #3322

This commit is contained in:
r888888888
2017-10-09 16:59:56 -07:00
parent 0bb2dae5f6
commit 51867a8c64
2 changed files with 10 additions and 4 deletions

View File

@@ -93,9 +93,15 @@ module ApplicationHelper
time_tag(time.strftime("%Y-%m-%d %H:%M"), time)
end
def external_link_to(url)
def external_link_to(url, options = {})
if options[:truncate]
text = truncate(url, length: options[:truncate])
else
text = url
end
if url =~ %r!\Ahttps?://!i
link_to url, url, {rel: :nofollow}
link_to text, url, {rel: :nofollow}
else
url
end