lib/onebox/engine/image_onebox.rb in onebox-1.7.3 vs lib/onebox/engine/image_onebox.rb in onebox-1.7.4
- old
+ new
@@ -9,15 +9,20 @@
WhitelistedGenericOnebox.host_matches(uri, WhitelistedGenericOnebox.https_hosts)
end
def to_html
# Fix Dropbox image links
- if /^https:\/\/www.dropbox.com\/s\//.match @url
- @url.gsub!("https://www.dropbox.com","https://dl.dropboxusercontent.com")
+ if @url[/^https:\/\/www.dropbox.com\/s\//]
+ @url.sub!("https://www.dropbox.com", "https://dl.dropboxusercontent.com")
end
- escaped = Onebox::Helpers.normalize_url_for_output(url)
- "<a href='#{escaped}' target='_blank'><img src='#{escaped}'></a>"
+ escaped_url = ::Onebox::Helpers.normalize_url_for_output(@url)
+
+ <<-HTML
+ <a href="#{escaped_url}" target="_blank">
+ <img src="#{escaped_url}">
+ </a>
+ HTML
end
end
end
end