From f3d319f4567d253977217963c1910e83eeb8c0af Mon Sep 17 00:00:00 2001 From: mtfcd Date: Fri, 2 Feb 2024 22:50:28 +0800 Subject: [PATCH] fix: add host before url only if it starts with '/', otherwise it probably starts with 'http' chore: autoformat with stylua --- lua/rest-nvim/request/init.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/rest-nvim/request/init.lua b/lua/rest-nvim/request/init.lua index a6a083fd..377ae805 100644 --- a/lua/rest-nvim/request/init.lua +++ b/lua/rest-nvim/request/init.lua @@ -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)