@@ -197,6 +197,18 @@ function client.request(request)
197
197
ssl_verifypeer = skip_ssl_verification ,
198
198
})
199
199
200
+ -- Encode URL query parameters and set the request URL again with the encoded values
201
+ local should_encode_url = _G ._rest_nvim .encode_url
202
+ if should_encode_url then
203
+ -- Create a new URL as we cannot extract the URL from the req object
204
+ local _url = curl .url ()
205
+ _url :set_url (request .request .url )
206
+ -- Re-add the request query with the encoded parameters
207
+ _url :set_query (_url :get_query (), curl .U_URLENCODE )
208
+ -- Re-add the request URL to the req object
209
+ req :setopt_url (_url :get_url ())
210
+ end
211
+
200
212
-- Set request HTTP version, defaults to HTTP/1.1
201
213
if request .request .http_version then
202
214
local http_version = request .request .http_version :gsub (" %." , " _" )
@@ -269,7 +281,14 @@ function client.request(request)
269
281
ret .statistics = get_stats (req , stats_config .stats )
270
282
end
271
283
272
- ret .url = req :getinfo_effective_url ()
284
+ -- Returns the decoded URL if the request URL was encoded by cURL to improve the results
285
+ -- buffer output readability.
286
+ -- NOTE: perhaps make this configurable in case someone wants to see the encoded URL instead?
287
+ if should_encode_url then
288
+ ret .url = request .request .url
289
+ else
290
+ ret .url = req :getinfo_effective_url ()
291
+ end
273
292
ret .code = req :getinfo_response_code ()
274
293
ret .method = req :getinfo_effective_method ()
275
294
ret .headers = table.concat (res_headers ):gsub (" \r " , " " )
0 commit comments