Commit 0b8e42d9 authored by Aral Balkan's avatar Aral Balkan
Browse files

Clean up state code

parent 3375909c
......@@ -30,21 +30,17 @@ function currentSectionFromHash (signedIn) {
}
// Normalise all paths so they do not end in a slash.
if (section !== '/' && section.endsWith('/')) {
section = section.slice(0, section.length - 1)
}
if (section !== '/' && section.endsWith('/')) { section = section.slice(0, section.length - 1) }
// Normalise index path.
if (section === '') { section = '/';}
if (section === '') { section = '/'; }
if (section !== location.hash.replace('#', '')) {
location.hash = section
}
// If we’ve updated the section path, update the hash also.
if (section !== location.hash.replace('#', '')) { location.hash = section }
// Check if this is a known path and show 404 page if it’s not.
if (!sectionPaths.includes(section)) {
section = '/404'
}
// (Note: we do not update the hash here on purpose so the original missing path is shown.)
if (!sectionPaths.includes(section)) { section = '/404' }
return section
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment