fix(liveview): don't double the ? and # when reading the browser location - #5836
Merged
nicoburns merged 1 commit intoSep 16, 2026
Merged
Conversation
…location `location.search` and `location.hash` already start with `?` and `#`, so LiveviewHistory built routes like `/search??query=hello#` and `##top`. The router then saw a query key of `?query`, which silently dropped the first query parameter on page load and after back/forward navigation. Build the route the same way the web history does: pathname + search + hash.
nicoburns
approved these changes
Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was reading
packages/liveview/src/history.rsnext to the web history and noticed the two read the browser location differently. The web history builds the route aspathname + search + hash, while LiveviewHistory doespathname + "?" + search + "#" + hash.location.searchandlocation.hashalready include their leading?and#, so forhttp://localhost/search?query=hello&word_count=8#topLiveviewHistory produces/search??query=hello&word_count=8##top. That happens both in the initial eval and in thepopstatelistener.The router's
from_strsplits on the first#and?, so the query it sees is?query=hello&word_count=8: the first key becomes?query, which matches nothing, and the parameter is silently dropped. A plain path without a query ends up as/path?#, which is why this doesn't show up in the basic case.To check it, I wrote a throwaway test in
packages/router/tests(not part of this PR) that pulls the exact JS expression out ofhistory.rs, runs it with node against a mockeddocument.location, and parses the result with a#[route("/search?:query&:word_count")]enum:Before:
After:
cargo check -p dioxus-liveviewpasses. The change only touches the JS string inside the crate-privateLiveviewHistory, and the separators aren't lost since they come fromsearchandhashthemselves, so the route string now matches what the web renderer already gives the router. From reading the code, the same string is also passed back tohistory.replaceState, so the doubled??/##would end up in the address bar too, but I only verified the parsing side, not a running liveview app.AI tools used