Storage = { getItem: (key, fallback) => { if (!localStorage.hasOwnProperty(key)) { localStorage.setItem(key, fallback); } return localStorage.getItem(key); }, setItem: (key, val) => { localStorage.setItem(key, val); }, }; const fixURL = (urlStr) => { const url = new URL(urlStr); url.protocol = document.location.protocol; url.port = document.location.port; return url.toString(); };