Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent window.location.href from encoding url

I want to redirect the user to the url "/some/link+with+garbage/". When I use window.location.href="/some/link+with+garbage/"

I'm redirected to "/some/link%2Bwith%2Bgarbage/" which fails.

Is there a way to prevent window.location.href from encoding the url?

like image 512
a_bigbadwolf Avatar asked May 21 '26 08:05

a_bigbadwolf


1 Answers

If anyone runs into this issue, the problem is not with the encoding of the url but another problem in my code. I tried to read from the url after page load and failed to properly decode the url using decodeURIComponent(window.location.href).

Rookie mistake. Thanks for the help.

like image 63
a_bigbadwolf Avatar answered May 22 '26 22:05

a_bigbadwolf