Encode and decode URL
🏷️ Javascript
Encode URL
encodeURI()
: encode a full URL. It doesn’t encode~!@#$&*()=:/,;?+'
encodeURIComponent()
: encode a part of the URL. It doesn’t encode-_.!~*'()
Decode URL
Use decodeURI()
and decodeURIComponent()
to decode corresponding encoding function’s result
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent