From 0dec98f50add774593639c8fd7d70550c74dd68f Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Thu, 14 Jan 2016 18:30:06 +0530 Subject: [PATCH] FIX: CDN URL should start with protocol --- app/assets/javascripts/discourse/lib/utilities.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/lib/utilities.js b/app/assets/javascripts/discourse/lib/utilities.js index 266047c78b5..fa1f063f01a 100644 --- a/app/assets/javascripts/discourse/lib/utilities.js +++ b/app/assets/javascripts/discourse/lib/utilities.js @@ -262,7 +262,11 @@ Discourse.Utilities = { return ''; } else if (!Discourse.SiteSettings.prevent_anons_from_downloading_files && (/\.(mov|mp4|webm|ogv|mp3|ogg|wav)$/i).test(upload.original_filename)) { // is Audio/Video - return Discourse.CDN ? Discourse.getURLWithCDN(upload.url) : "http://" + Discourse.BaseUrl + upload.url; + if (Discourse.CDN) { + return Discourse.CDN.startsWith('//') ? "http:" + Discourse.getURLWithCDN(upload.url) : Discourse.getURLWithCDN(upload.url); + } else { + return "http://" + Discourse.BaseUrl + upload.url; + } } else { return '' + upload.original_filename + ' (' + I18n.toHumanSize(upload.filesize) + ')'; }