2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

PERF: Move oneboxing from cook method "email" to postprocessing

This commit is contained in:
Gerhard Schlager 2017-10-17 20:36:57 +02:00
parent d3003592cd
commit 1481462cbf
2 changed files with 12 additions and 11 deletions

View file

@ -21,12 +21,11 @@ class EmailCook
str.scan(EmailCook.url_regexp).each do |m|
url = m[0]
val = "<a href='#{url}'>#{url}</a>"
# Onebox consideration
if str.strip == url
oneboxed = Oneboxer.onebox(url)
val = oneboxed if oneboxed.present?
# this could be oneboxed
val = %|<a href="#{url}" class="onebox" target="_blank">#{url}</a>|
else
val = %|<a href="#{url}">#{url}</a>|
end
str.gsub!(url, val)