diff --git a/lib/global_path.rb b/lib/global_path.rb index 10d1fbdda56..17479b60ebb 100644 --- a/lib/global_path.rb +++ b/lib/global_path.rb @@ -11,7 +11,8 @@ module GlobalPath if SiteSetting.Upload.s3_cdn_url.present? p = Discourse.store.cdn_url(p) end - p =~ /^http/ ? p : cdn_path(p) + + (p =~ /^http/ || p =~ /^\/\//) ? p : cdn_path(p) end def cdn_relative_path(path) diff --git a/spec/helpers/user_notifications_helper_spec.rb b/spec/helpers/user_notifications_helper_spec.rb index 735a69e19bb..f1aeb8a4c94 100644 --- a/spec/helpers/user_notifications_helper_spec.rb +++ b/spec/helpers/user_notifications_helper_spec.rb @@ -108,6 +108,16 @@ describe UserNotificationsHelper do ) 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 before do SiteSetting.s3_cdn_url = 'https://some.cdn.com'