FIX: user avatar in oneboxes/quotes when using CDN

This commit is contained in:
Régis Hanol 2015-07-15 23:00:11 +02:00
parent 25a1bf421e
commit ea16797761
1 changed files with 7 additions and 12 deletions

View File

@ -11,28 +11,23 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
_docTitle: document.title, _docTitle: document.title,
getURL: function(url) { getURL: function(url) {
if (!url) { return url; } if (!url) return url;
// If it's a non relative URL, return it. // if it's a non relative URL, return it.
if (url.indexOf('http') === 0) return url; if (!/^\/[^\/]/.test(url)) return url;
var u = (Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri); var u = (Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri);
if (u[u.length-1] === '/') {
u = u.substring(0, u.length-1);
}
if (url.indexOf(u) !== -1) return url;
if(u.length > 0 && url[0] !== "/") { if (u[u.length-1] === '/') u = u.substring(0, u.length-1);
// we got to root this if (url.indexOf(u) !== -1) return url;
url = "/" + url; if (u.length > 0 && url[0] !== "/") url = "/" + url;
}
return u + url; return u + url;
}, },
getURLWithCDN: function(url) { getURLWithCDN: function(url) {
url = this.getURL(url); url = this.getURL(url);
// https:// and http:// and // should be skipped, only /xyz is allowed here // only relative urls
if (Discourse.CDN && /^\/[^\/]/.test(url)) { if (Discourse.CDN && /^\/[^\/]/.test(url)) {
url = Discourse.CDN + url; url = Discourse.CDN + url;
} else if (Discourse.S3CDN) { } else if (Discourse.S3CDN) {