Encoding a URI parameters

98 Views Asked by At

Some of our GET request pass paramaters in the URI and in as a request parameter. So in firebug you'd see the same parameter in the URI and you'd see it also on the params tab for the request.

When the parameter values needs to be encoded e.g. it is %, I see it encoded in the URI as %25 but I don't see it being encoded on the params tab.

The requests are being made using Angular.

I am wondering is it only when the parameter in the URI that it needs to encoded? Or do I need to be consistent here?

Thanks

1

There are 1 best solutions below

0
Manuel van Rijn On

you should encode your url/parameters using encodeURIComponent(url_or_params)

see: http://www.w3schools.com/jsref/jsref_encodeuricomponent.asp