fix get from url for external uploads without CDN

This commit is contained in:
Maja Komel
2018-06-13 16:21:28 +10:00
committed by Sam
parent 0c2f590c64
commit 6c9190357c
2 changed files with 9 additions and 0 deletions
+2
View File
@@ -79,6 +79,8 @@ class Upload < ActiveRecord::Base
return if url.blank?
# we store relative urls, so we need to remove any host/cdn
url = url.sub(Discourse.asset_host, "") if Discourse.asset_host.present? && Discourse.asset_host != SiteSetting.Upload.s3_cdn_url
# when using s3 without CDN
url = url.sub(/^https?\:/, "") if url.include?(Discourse.store.absolute_base_url) && Discourse.store.external?
# when using s3, we need to replace with the absolute base url
url = url.sub(SiteSetting.Upload.s3_cdn_url, Discourse.store.absolute_base_url) if SiteSetting.Upload.s3_cdn_url.present?