1var myUrl = "http://www.image.com/?username=unknown&password=unknown";
2var encodedURL= "http://www.foobar.com/foo?imageurl=" + encodeURIComponent(myUrl);
3
1const uri = 'https://mozilla.org/?x=шеллы';
2const encoded = encodeURI(uri);
3console.log(encoded);
4// expected output: "https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"