Skip to content

Commit 2f767b7

Browse files
mtfcdNTBBloodbath
authored andcommitted
add host before url only if it starts with '/', otherwise it probably starts with 'http'
1 parent cd366b6 commit 2f767b7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lua/rest-nvim/request/init.lua

Lines changed: 6 additions & 3 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

@@ -329,7 +332,7 @@ end
329332
-- full_body boolean
330333
M.stringify_request = function(req, opts)
331334
opts = vim.tbl_deep_extend(
332-
"force", -- use value from rightmost map
335+
"force", -- use value from rightmost map
333336
{ full_body = false, headers = true }, -- defaults
334337
opts or {}
335338
)

0 commit comments

Comments
 (0)