FIX: Oneboxing root domains could stop previewing
This commit is contained in:
parent
4112c2b883
commit
bd70656b90
|
@ -19,7 +19,7 @@ function loadNext(ajax) {
|
||||||
data: { url, refresh, user_id: userId },
|
data: { url, refresh, user_id: userId },
|
||||||
cache: true
|
cache: true
|
||||||
}).then(html => {
|
}).then(html => {
|
||||||
localCache[url] = html;
|
localCache[normalize(url)] = html;
|
||||||
$elem.replaceWith(html);
|
$elem.replaceWith(html);
|
||||||
}, result => {
|
}, result => {
|
||||||
if (result && result.jqXHR && result.jqXHR.status === 429) {
|
if (result && result.jqXHR && result.jqXHR.status === 429) {
|
||||||
|
@ -27,7 +27,7 @@ function loadNext(ajax) {
|
||||||
removeLoading = false;
|
removeLoading = false;
|
||||||
loadingQueue.unshift({ url, refresh, $elem, userId });
|
loadingQueue.unshift({ url, refresh, $elem, userId });
|
||||||
} else {
|
} else {
|
||||||
failedCache[url] = true;
|
failedCache[normalize(url)] = true;
|
||||||
}
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
timeout = Ember.run.later(() => loadNext(ajax), timeoutMs);
|
timeout = Ember.run.later(() => loadNext(ajax), timeoutMs);
|
||||||
|
@ -52,11 +52,11 @@ export function load(e, refresh, ajax, userId, synchronous) {
|
||||||
// Unless we're forcing a refresh...
|
// Unless we're forcing a refresh...
|
||||||
if (!refresh) {
|
if (!refresh) {
|
||||||
// If we have it in our cache, return it.
|
// If we have it in our cache, return it.
|
||||||
const cached = localCache[url];
|
const cached = localCache[normalize(url)];
|
||||||
if (cached) return cached;
|
if (cached) return cached;
|
||||||
|
|
||||||
// If the request failed, don't do anything
|
// If the request failed, don't do anything
|
||||||
const failed = failedCache[url];
|
const failed = failedCache[normalize(url)];
|
||||||
if (failed) return;
|
if (failed) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +74,12 @@ export function load(e, refresh, ajax, userId, synchronous) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function lookupCache(url) {
|
// Sometimes jQuery will return URLs with trailing slashes when the
|
||||||
return localCache[url];
|
// `href` didn't have them.
|
||||||
|
function normalize(url) {
|
||||||
|
return url.replace(/\/$/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function lookupCache(url) {
|
||||||
|
return localCache[normalize(url)];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue