FIX: Incorrect CDN URL for site setting uploads when s3 is enabled.

This commit is contained in:
Guo Xiang Tan 2019-01-04 07:50:35 +08:00
parent 6961a4f43e
commit 5f0f7f909d
2 changed files with 12 additions and 1 deletions

View File

@ -11,7 +11,8 @@ module GlobalPath
if SiteSetting.Upload.s3_cdn_url.present? if SiteSetting.Upload.s3_cdn_url.present?
p = Discourse.store.cdn_url(p) p = Discourse.store.cdn_url(p)
end end
p =~ /^http/ ? p : cdn_path(p)
(p =~ /^http/ || p =~ /^\/\//) ? p : cdn_path(p)
end end
def cdn_relative_path(path) def cdn_relative_path(path)

View File

@ -108,6 +108,16 @@ describe UserNotificationsHelper do
) )
end end
describe 'when global cdn path is configured' do
it 'should return the right url' do
GlobalSetting.stubs(:cdn_url).returns('https://some.cdn.com/cluster')
expect(helper.logo_url).to eq(
"http://s3-upload-bucket.s3.dualstack.us-east-1.amazonaws.com/original/1X/somesha1.png"
)
end
end
describe 'when cdn path is configured' do describe 'when cdn path is configured' do
before do before do
SiteSetting.s3_cdn_url = 'https://some.cdn.com' SiteSetting.s3_cdn_url = 'https://some.cdn.com'