Percent-encoding in short
URLs may contain only a limited set of ASCII characters. Anything else — spaces, &, =, non-English letters — is written as % followed by the byte’s two hex digits in UTF-8. A space becomes %20 (or + in form data), é becomes %C3%A9.
Component vs. full URL encoding
- Component (
encodeURIComponent) encodes everything except letters, digits and-_.!~*'(). Use it for a single query value. - Full URL (
encodeURI) keeps: / ? & = #so the URL’s structure survives. Use it for a whole URL that contains spaces.