Sign In Register

How can we help you today?

Start a new topic

Http URL escaping

Hello,

is in Cloud Code some kind of functionality that allow to make url escaping? I mean to make from this "http://url.com?name=Name With Spaces" to "http://url.com?name=Name%20With%20Spaces" and of course changing other unallowed signs in url?


Hi Marcin,


You can use encodeURIComponent & decodeURIComponent to do this in Cloud Code.


var url = "http://url.com?name=Name With Spaces"

var res = encodeURIComponent(url);
var res2 = decodeURIComponent(res);

Spark.setScriptData("encoded", res)
Spark.setScriptData("decoded", res2)


response scriptData should be this

"scriptData": {
  "decoded": "http://url.com?name=Name With Spaces",
  "encoded": "http%3A%2F%2Furl.com%3Fname%3DName%20With%20Spaces"

   

Hope that helps, if you have any further questions just let me know.


Thanks,

Liam

Great thank you for help:)

 

Login to post a comment