discourse/app/assets/javascripts/pretty-text/addon/oneboxer-cache.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
576 B
JavaScript
Raw Normal View History

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;
}