Skip to content

Commit

Permalink
update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
smtdfc committed Mar 10, 2024
1 parent 970ad78 commit dea3787
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/modules/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,32 @@ export class TurtleRouterModule {
}

start() {
window.addEventListener("hashchange", function() {
let path = window.location.hash
if (path.length == 0) {
window.location.hash = "#!/"
path = "/"
} else {
path = path.slice(2)
}
this.matches(path)
}.bind(this))

let started = false
let path = window.location.hash

if (path.length == 0) {
window.location.hash = "#!/"
path = "/"
} else {
path = path.slice(2)
}

window.addEventListener("hashchange", function() {
if (started) {
let path = window.location.hash
if (path.length == 0) {
path = "/"
} else {
path = path.slice(2)
}
this.matches(path)
}

}.bind(this))



this.matches(path)
started = true
}

redirect(path, replace = false) {
Expand Down

0 comments on commit dea3787

Please sign in to comment.