Which option should I pick?
- Encode everything — for a single value you'll put inside a URL, like a search term or a redirect URL passed as a parameter. Same as JavaScript's
encodeURIComponent. - Keep URL structure — for a complete URL that contains spaces or non-English characters. Same as
encodeURI. - Form style — the format browsers use when submitting forms, with spaces as
+.
Example
The search shoes & socks as a query value becomes shoes%20%26%20socks, so the URL ?q=shoes%20%26%20socks&page=2 still has exactly two parameters. Without encoding, the & would split it into three.


