Skip to content

Commit

Permalink
fix: add host before url only if it starts with '/', otherwise it pro…
Browse files Browse the repository at this point in the history
…bably starts with 'http'

chore: autoformat with stylua
  • Loading branch information
mtfcd authored and NTBBloodbath committed Feb 12, 2024
1 parent 3e0d86d commit f3d319f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 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

0 comments on commit f3d319f

Please sign in to comment.