EncodeURI in javascript (velo) returns unexpected value

220 Views Asked by At

I've been trying to get value from encodeURI in id. This code in javascript is in velo (wix) plataform coding.

Every trying the id get encode in the first characters but not complete and unexpected. Let me show the code :

let id = "583b58eb-708e-4eba-bb8d-af7f4841f";
let userDetails = JSON.stringify({ id });
let uri = `https://www.dasdqer.aereg/vfe/?user=${encodeURIComponent(userDetails)}`;
let encodeURICOMP = encodeURI(uri);
console.log(encodeURICOMP);

Always return something like this in the end, but not exactly, this is another example with another object with same struture Example of unexpected return

This start to encoding but after some characters stop to encoding. What should I do? Is there in encodeURI to retire this limit too ?

1

There are 1 best solutions below

0
Fraser On BEST ANSWER

encodeURIComponent() escapes all characters except:

A-Z a-z 0-9 - _ . ! ~ * ' ( )

see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent

So it is working exactly as expected.

encodeURI() escapes all characters except:

A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) #

see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI

So it too is working exactly as expected.