Looking to develop a bookmarklet that adds the current page's URL to a specific pre-set URL.
javascript:(function(){location.href='example.com/u='+encodeURIComponent(location.href)}());
Even though when I double encode the returned URL using
encodeURIComponent(encodeURIComponent(location.href))
, it works fine. Can someone explain why doubling encodeURIComponent has this effect?