How can I encode javascript arrays in url?
eg: The following is my query param
/query?colors=['red','blue','green',]
expected output
%5B%27red%27%2C%27blue%27%2C%27green%27%2C%5D
I've tried encodeURI and encodeURIComponent, but the comma is not getting transformed in to %2C.
UPDATE I tried this
let colors = ['red','green']
encodeURIComponent(JSON.stringify(colors))
colors=%255B%2522red%2522%252C%2522green%2522%255D.
But when I does so additional characters 25 is getting added. How Can I prevent that?