Skip to content

Commit f3d319f

Browse files
mtfcdNTBBloodbath
authored andcommitted
fix: add host before url only if it starts with '/', otherwise it probably starts with 'http'
chore: autoformat with stylua
1 parent 3e0d86d commit f3d319f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lua/rest-nvim/request/init.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,11 @@ M.buf_get_request = function(bufnr, curpos)
290290
local curl_args, body_start = get_curl_args(bufnr, headers_end, end_line)
291291

292292
local host = headers[utils.key(headers, "host")] or ""
293-
parsed_url.url = host:gsub("%s+", "") .. parsed_url.url
294-
headers[utils.key(headers, "host")] = nil
293+
294+
if string.sub(parsed_url.url, 1, 1) == "/" then
295+
parsed_url.url = host:gsub("%s+", "") .. parsed_url.url
296+
headers[utils.key(headers, "host")] = nil
297+
end
295298

296299
local body = get_body(bufnr, body_start, end_line)
297300

0 commit comments

Comments
 (0)