I'm trying to make a redirect using router.push to pass a query string, but when I try to pass a value in my param with special characters as a comma is encoding my URL. Is it possible to pass ',' into an URL using router.push?
I have tried a lot of things but I don't know how to make it work.
router.push({
pathname: router.pathname,
query: { ...router.query, pets: 'cats,dogs'},
})
The resulting URL will be myurl?pets=cats%2Cdogs, I want it to be myurl?pets=cats,dogs.
Using the URL object format for the path and query string will internally encode the query parameters.
To avoid this, you can pass the path and query string as a string instead.
router.push(`${router.asPath}?pets=cats,dogs`)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With