Skip to content

Commit 38ceda9

Browse files
flexagoonNTBBloodbath
authored andcommitted
fix: correctly urlencode query parameters (fixes #317)
1 parent 3fc2bb8 commit 38ceda9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/rest-nvim/client/curl.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ function client.request(request)
204204
local _url = curl.url()
205205
_url:set_url(request.request.url)
206206
-- Re-add the request query with the encoded parameters
207-
_url:set_query(_url:get_query(), curl.U_URLENCODE)
207+
local query = _url:get_query()
208+
if type(query) == "string" then
209+
_url:set_query('')
210+
for param in vim.gsplit(query, "&") do
211+
_url:set_query(param, curl.U_URLENCODE + curl.U_APPENDQUERY)
212+
end
213+
end
208214
-- Re-add the request URL to the req object
209215
req:setopt_url(_url:get_url())
210216
end

0 commit comments

Comments
 (0)