FIX: CDN URL should start with protocol

This commit is contained in:
Arpit Jalan 2016-01-14 18:30:06 +05:30
parent d2c297955a
commit 0dec98f50a
1 changed files with 5 additions and 1 deletions

View File

@ -262,7 +262,11 @@ Discourse.Utilities = {
return '<img src="' + upload.url + '" width="' + upload.width + '" height="' + upload.height + '">';
} 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 '<a class="attachment" href="' + upload.url + '">' + upload.original_filename + '</a> (' + I18n.toHumanSize(upload.filesize) + ')';
}