blog

encodeURI vs encodeURIComponent

TL;DR: use encodeURI for encoding full URLs and encodeURIComponent for parts of link (like query strings, mailto: and sms: body strings) or any kind of string NOT used as URL.

Reference links: