Component vs full URL
Encode uses encodeURIComponent: it escapes everything except letters, digits and - _ . ! ~ * ' ( ). Use it for a single query value or path segment. Encode full URL uses encodeURI, which keeps characters that structure a URL, such as : / ? # & =.
Decoding
Decoding converts %XX sequences back to characters and treats + as a space, as in form submissions. A lone % or an invalid UTF-8 sequence produces an error rather than wrong output.
Common mistake
Encoding an already encoded value turns %20 into %2520. Encode each value once, just before building the URL.