Closed stopbystudent closed 1 year ago
Yup definitely a bug. I think it's because we try to parse the URL but don't succeed because the parser has no knowledge of query params yet. A simple fix should just be to ignore everything after a ?
character in the URL parser.
Describe the bug
In my application, I have a URL that takes query parameters. They are extracted by the router using JavaScript which works well. Now if I call my app with
/?filter=text
I expect it to receive the query parameter. That indeed works if called directly from the browser's URL bar (typing it manually). Coming from sycamore, however, this has two interesting variations:sycamore_router::navigate("/?filter=text")
I end up on my 404 page because apparently the router tries to resolve the full page by name instead of trying to resolve/
and passing on all query parameters as is. The address bar of the browser, however, contains the correct address/?filter=text
; manually reloading the page indeed gets me to the right page with all query parameters present.a(href = "/?filter=text") { "Link" }
I end up on the page for/
but with all query parameters cleared, i.e. the filter parameter did not make it to the routed endpoint.Losing the query parameters while navigating or having to manually reload is a bug, in my opinion.
To Reproduce
Expected behavior
I expect sycamore-router to be query-parameter-agnostic, i.e. even while #130 is unresolved I expect sycamore-router to pass on query parameters as is, neither ignoring them (the
a(href
case) nor leading to 404 pages (thenavigate
case).Furthermore, navigate should not behave differently from what the
href
interceptor does ona
tags in this regard.Environment