From 06e3654a33dd72e8be56795c028e6259ee88177b Mon Sep 17 00:00:00 2001 From: Kai O'Reilly Date: Tue, 19 Nov 2024 16:55:53 -0800 Subject: [PATCH] don't push in Content.saveWebURL if we are already at the new URL; fully fixes #1279 by removing duplicate history entries for first page --- content/url_js.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/content/url_js.go b/content/url_js.go index 639c7b47a..46766d7f3 100644 --- a/content/url_js.go +++ b/content/url_js.go @@ -7,7 +7,6 @@ package content import ( - "fmt" "net/url" "strings" "syscall/js" @@ -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 } @@ -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()) }