Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Small Web
henry
Commits
0b8e42d9
Commit
0b8e42d9
authored
Jan 24, 2021
by
Aral Balkan
Browse files
Clean up state code
parent
3375909c
Changes
1
Hide whitespace changes
Inline
Side-by-side
state.js
View file @
0b8e42d9
...
...
@@ -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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment