discourse/frontend/pretty-text/addon/oneboxer-cache.js
David Taylor d1e1c02fcb DEV: Rename app/assets/javascripts/ -> frontend/
Commit created with `mv app/assets/javascripts frontend && git add .`
2025-10-22 16:24:11 +01:00

28 lines
576 B
JavaScript

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) {
return localCache[normalize(url)]?.outerHTML;
}