Skip to content

Commit

Permalink
don't push in Content.saveWebURL if we are already at the new URL; fu…
Browse files Browse the repository at this point in the history
…lly fixes #1279 by removing duplicate history entries for first page
  • Loading branch information
kkoreilly committed Nov 20, 2024
1 parent 793baf7 commit 06e3654
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions content/url_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package content

import (
"fmt"
"net/url"
"strings"
"syscall/js"
Expand Down Expand Up @@ -45,7 +44,7 @@ func (ct *Content) saveWebURL() {
if firstContent != ct {
return
}
_, base, err := getURL()
current, base, err := getURL()
if errors.Log(err) != nil {
return
}
Expand All @@ -54,7 +53,9 @@ func (ct *Content) saveWebURL() {
return
}
fullNew := base.ResolveReference(new)
fmt.Println("push", fullNew.String())
if fullNew.String() == current.String() {
return // We are already at this URL, so don't push it again
}
js.Global().Get("history").Call("pushState", "", "", fullNew.String())
}

Expand Down

0 comments on commit 06e3654

Please sign in to comment.