diff --git a/pages/pass.tsx b/pages/pass.tsx index 863a154..1af5b0a 100644 --- a/pages/pass.tsx +++ b/pages/pass.tsx @@ -11,7 +11,7 @@ function Pass(): JSX.Element { function closeViewer() { setFragment(undefined); - window.location.href = '/'; + window.location.replace('/'); } useEffect(() => { @@ -19,12 +19,6 @@ function Pass(): JSX.Element { const decodedFragment = Buffer.from(rawFragment, 'base64').toString(); setFragment(decodedFragment); - window.location.replace('#'); - if (typeof window.history.replaceState == 'function') { - const href = window.location.href; - history.replaceState({}, '', href.slice(0, href.lastIndexOf('/'))); - } - document.addEventListener('visibilitychange', () => { if (document.hidden) { closeViewer(); @@ -32,6 +26,8 @@ function Pass(): JSX.Element { }); window.addEventListener('blur', closeViewer); + window.addEventListener('beforeunload', closeViewer); + window.addEventListener('pagehide', closeViewer); }, []); return ( diff --git a/pages/privacy.tsx b/pages/privacy.tsx index 13bd2f0..e450a74 100644 --- a/pages/privacy.tsx +++ b/pages/privacy.tsx @@ -152,7 +152,7 @@ function Privacy(): JSX.Element {