mirror of
https://github.com/discourse/discourse.git
synced 2024-12-22 02:26:17 +08:00
30 lines
618 B
Plaintext
30 lines
618 B
Plaintext
|
export let localCache = {};
|
||
|
export let failedCache = {};
|
||
|
|
||
|
// Sometimes jQuery will return URLs with trailing slashes when the
|
||
|
// `href` didn't have them.
|
||
|
export function resetLocalCache() {
|
||
|
localCache = {};
|
||
|
}
|
||
|
|
||
|
export function resetFailedCache() {
|
||
|
failedCache = {};
|
||
|
}
|
||
|
|
||
|
export function setLocalCache(key, value) {
|
||
|
localCache[key] = value;
|
||
|
}
|
||
|
|
||
|
export function setFailedCache(key, value) {
|
||
|
failedCache[key] = value;
|
||
|
}
|
||
|
|
||
|
export function normalize(url) {
|
||
|
return url.replace(/\/$/, "");
|
||
|
}
|
||
|
|
||
|
export function lookupCache(url) {
|
||
|
const cached = localCache[normalize(url)];
|
||
|
return cached && cached.prop("outerHTML");
|
||
|
}
|