showing results for - "convert path string to url encoding javascript"
Della
08 Mar 2016
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"
5
6try {
7  console.log(decodeURI(encoded));
8  // expected output: "https://mozilla.org/?x=шеллы"
9} catch (e) { // catches a malformed URI
10  console.error(e);
11}
Valeria
16 May 2016
1var myOtherUrl = 
2       "http://example.com/index.html?url=" + encodeURIComponent(myUrl);