Mode
About URL encoding
Percent-encoding replaces unsafe characters with a % followed by two hex digits representing their UTF-8 byte values. Component mode (encodeURIComponent) is the right choice when encoding a single query-string value or path segment, it escapes structural characters like &, =, and / that would otherwise be interpreted by the parser. Whole URL mode (encodeURI) preserves those structural characters, making it suitable when you have a complete URL that just needs non-ASCII or space characters encoded. Decoding uses the matching function and will show an error on malformed sequences such as a lone % or truncated escape.