From 6da1e48991c3c34c8cb29713c0341e6fb411d7b6 Mon Sep 17 00:00:00 2001 From: Arpith Siromoney Date: Sun, 2 Jan 2022 22:21:13 -0800 Subject: [PATCH] main: use window.location.hash for article IDs --- src/main.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main.js b/src/main.js index acd4173..fff32d1 100644 --- a/src/main.js +++ b/src/main.js @@ -14,7 +14,7 @@ const splitPathname = window.location.pathname.split('/'); const isArticle = splitPathname[splitPathname.length - 1] === 'articles'; const labelArticles = {}; const userLinkDiv = document.getElementById('userLinkContainer'); -let hash = splitPathname.pop(); +let hash = window.location.hash; let pathname = splitPathname.join('/'); let current; let articles; @@ -123,7 +123,7 @@ function updateState() { const articleTitle = articleDiv.childNodes[0].firstChild.innerHTML; const feedTitle = articleDiv.childNodes[1].firstChild.innerHTML; document.title = `${articleTitle} - ${feedTitle} (feedreader.co)`; - history.replaceState({ id: current.id }, '', `https://${window.location.hostname}${pathname}${current.id}`); + history.replaceState({ id: current.id }, '', `https://${window.location.hostname}${pathname}#${current.id}`); if (token) { console.log(`Marking ${id} as read`); lib.user.labels.post('read', id).then(() => { @@ -137,11 +137,6 @@ function updateState() { pathname = `${pathname}/`; -if ((hash.length !== 32) && (hash.length !== 40)) { - pathname = `${pathname}${hash}/`; - hash = ''; -} - window.onscroll = updateState; if (!user) {