Assuming www.mydomain.com?param1=example
as an example.
What is the best way to store a second parameter that is a list of key value pairs? At the minute I use ¶m2=key|value,key|value
. I separate the key from the value using a vertical line, and the pairing with a comma, everything after the equals is encoded using encodeURIComponent()
. This works fine.
However, the user has control of the value... And as sensible human beings we all know that the first thing the user will probably do is stick a vertical bar or a comma as one of the values breaking my parameter parser. Is there a better way to do this? I've seen PHP users talking about storing associated arrays in urls but I'm looking for a pure javascript solution.