T
TanStack11mo ago
wise-white

How to correctly account for space character in search params

Hello, When I use this code to navigate to a page with given search params, it puts "foo+bar" in to the url. Then, when I click back it navigates to "foo%20bar" with the correct encoding for the space character. Am I using navigate incorrectly? How can I make it correctly encode the space? Thanks
navigate({
to: `/search`,
search: { query: "foo bar" },
})
navigate({
to: `/search`,
search: { query: "foo bar" },
})
2 Replies
fair-rose
fair-rose11mo ago
a complete minimal example would be helpful to debug this. can you please create one by forking one of the examples on stackblitz?
wise-white
wise-whiteOP10mo ago
@Manuel Schiller It appears someone just forgot to invoke preventDefault on a form submission that was calling navigate. So, it was encoding correctly then the form submission would break it. Thanks for replying!

Did you find this page helpful?