bruno
bruno copied to clipboard
Alow Bruno to URL-encode query params, similar to curl's `--url-query`
Hello! An API we have to use has query params that need to be URL encoded. We can do this with curl like this:
curl https://endpoint.com/path --url-query "results=a,b,c"
However, when trying Bruno, I realized I had to manually URL encode this myself:
Is there a way to be able to add query params that need to be URL encoded in Bruno? Perhaps similar to the "Body" dropdown (see next screenshot for example) that allows Form Encoding:
To add a little more context to this, I tested two other HTTP clients (Hurl - Run and Test HTTP Requests and REST Client - Visual Studio Marketplace) and they each auto-URL-encode query params for me. I'm not sure that's the correct behavior, but it's something I need to ergonomically work with these params. Other than this, Bruno looks awesome, thanks for making it!
Hurl example
GET https://endpoint.com/path
[QueryStringParams]
results: a,b,c
REST Client example
GET https://endpoint.com/path
?results=a,b,c
+1
It looks like Postman implements this as a "setting" on the Request itself (not global), which is also handy:
+1
Reading a little into the code it seems like axios is being used to send requests and axios should be capable of this feature.
This might be a duplicate of #732
I would love to have this feature. For now, I've put this workaround into my Collection's Pre-Request Script, which splits the request URL into hostname, etc. and parameters, and URI encodes the parameters. So far it hasn't had any issues, but your mileage may vary:
req.setUrl(req.getUrl().replace(/(.+?\?).+/,'$1') + encodeURI(req.getUrl().replace(/.+?\?/,'')))
Oh, I'm just realizing now that one big issue with my work-around is that the variables aren't getting interpreted before the JavaScript runs (see #2690). I understood this initially, which is why I split the host and parameters apart, but I'm just realizing it makes using variables in the parameters impossible.