Skip to content

Commit

Permalink
fix: remove trailing '/' in url
Browse files Browse the repository at this point in the history
when converting path to query
  • Loading branch information
Stan-Stani committed Jan 21, 2024
1 parent 9873944 commit 21b3dbe
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions public/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', () => {
const currentUrl = window.location.href
const pathArr = currentUrl.split('/')
const pathArr = currentUrl.split('/minigames/')
if (pathArr.length) {
console.log('pathArr:', {...pathArr})
let queryValue = pathArr[pathArr.length - 1]
if (queryValue[queryValue.length - 1] === '/') {
queryValue = queryValue.slice(0, queryValue.length - 1)
}
window.location.href =
'/minigames?game=' + encodeURIComponent(pathArr[pathArr.length - 1])
'/minigames?game=' + encodeURIComponent(queryValue)
} else {
window.location.href = 'minigames'
console.error("Couldn't parse URL")
Expand Down

0 comments on commit 21b3dbe

Please sign in to comment.