Skip to content

Commit

Permalink
fix bug when headers have host (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
NTBBloodbath authored Feb 12, 2024
2 parents d0a2819 + 5f9f357 commit adbec62
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lua/rest-nvim/request/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,11 @@ M.buf_get_request = function(bufnr, curpos)
local curl_args, body_start = get_curl_args(bufnr, headers_end, end_line)

local host = headers[utils.key(headers, "host")] or ""
parsed_url.url = host:gsub("%s+", "") .. parsed_url.url
headers[utils.key(headers, "host")] = nil

if string.sub(parsed_url.url, 1, 1) == "/" then
parsed_url.url = host:gsub("%s+", "") .. parsed_url.url
headers[utils.key(headers, "host")] = nil
end

local body = get_body(bufnr, body_start, end_line)

Expand Down Expand Up @@ -329,7 +332,7 @@ end
-- full_body boolean
M.stringify_request = function(req, opts)
opts = vim.tbl_deep_extend(
"force", -- use value from rightmost map
"force", -- use value from rightmost map
{ full_body = false, headers = true }, -- defaults
opts or {}
)
Expand Down

0 comments on commit adbec62

Please sign in to comment.