Encode/Decode text are not equal

Hi guys!

I have an issue with encode/decode functions. For example I have this code to decode and then encode:

Decode this url with plugin:
%27horizontal%27%2C%20%5B%27%230e5dc2%27%2C%20%27%23041b38%27%5D

The result is: ‘horizontal’, [‘#0e5dc2’, ‘#041b38’]

This works fine! But if I encode the result with plugin/encode column the result is:

‘horizontal’%2C%20%5B’%230e5dc2’%2C%20’%23041b38’%5D

So, why I have a different result? I could use another function to have the first result? :sweat_smile:

Looks like it’s not encoding the single quotes. Maybe it doesn’t because it’s probably using encodeURIComponent which I’m finding does not encode certain characters because they don’t need to be.

Is it causing issues down the line? If so, you could run the encoded result through a template column to replace the single quotes with %27.

You could also try this with a javascript column if you want to encode it with just one column.

return encodeURIComponent(p1).replace(/[!'()*]/g, escape);

2 Likes

Thanks Jeff :slight_smile:

Yes it’s causing an issue, so I wil use the js column that you write me !

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.