I have this url from which I am trying to retrieve the queryParams.
%dw 2.0
output application/json
import * from dw::core::URL
---
{
queryParams : read(parseURI("https://google.com?token=abc%2FL℅2Bxyz%2F").query default "", "application/x-www-form-urlencoded")
}
Output
{
"queryParams": {
"token": "abc/L xyz/"
}
}
Based on url encoding, / is %2F
and + is %2B
. But in the output I got a space in place of +
.
I understand that parseURI is basically decoding the URI to just "token=abc/L+xyz/"
, but why does applying a read(data, "application/x-www-form-urlencoded") on top of it change the value to abc/L xyz/
?
I am trying understand this behavior as I am trying to retrieve the original URI. For that I did the below
encodeURIComponent(read(parseURI("https://google.com?token=abc%2FL℅2Bxyz%2F").query default "", "application/x-www-form-urlencoded").token)
The output for the above line of code is "abc%2F%20xyz%2F"
. So %2B
is getting converted to %20
.