Skip to content

Commit 042d6d2

Browse files
fix: remove unnecessary edits
1 parent e326b56 commit 042d6d2

File tree

4 files changed

+7
-21
lines changed

4 files changed

+7
-21
lines changed

lua/rest-nvim/curl/init.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ local function create_callback(curl_cmd, opts)
117117

118118
headers = utils.map(headers, function(value)
119119
local _, _, http, status = string.find(value, "^(HTTP.*)%s+(%d+)%s*$")
120-
vim.print(value, http, status)
121120

122121
if http and status then
123122
return http .. " " .. utils.http_status(tonumber(status))
@@ -132,7 +131,7 @@ local function create_callback(curl_cmd, opts)
132131

133132
res.headers = parse_headers(res.headers)
134133

135-
local content_type = utils.get_value(res.headers, "content-type")
134+
local content_type = res.headers[utils.key(res.headers, "content-type")]
136135
if content_type then
137136
content_type = content_type:match("application/([-a-z]+)") or content_type:match("text/(%l+)")
138137
end

lua/rest-nvim/init.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ local function splice_body(headers, payload)
100100
else
101101
lines = payload.body_tpl
102102
end
103-
local content_type = utils.get_value(headers, "content-type") or ""
103+
local content_type = headers[utils.key(headers, "content-type")] or ""
104104
local has_json = content_type:find("application/[^ ]*json")
105105

106106
local body = ""
@@ -139,9 +139,8 @@ end
139139
rest.run_request = function(req, opts)
140140
-- TODO rename result to request
141141
local result = req
142-
local curl_raw_args = config.get("skip_ssl_verification")
143-
and vim.list_extend(result.raw, { "-k" })
144-
or result.raw
142+
local curl_raw_args = config.get("skip_ssl_verification") and vim.list_extend(result.raw, { "-k" })
143+
or result.raw
145144
opts = vim.tbl_deep_extend(
146145
"force", -- use value from rightmost map
147146
defaultRequestOpts,
@@ -153,8 +152,7 @@ rest.run_request = function(req, opts)
153152
local spliced_body = nil
154153
if not req.body.inline and req.body.filename_tpl then
155154
curl_raw_args = vim.tbl_extend("force", curl_raw_args, {
156-
"--data-binary",
157-
"@" .. load_external_payload(req.body.filename_tpl),
155+
"--data-binary", "@" .. load_external_payload(req.body.filename_tpl),
158156
})
159157
else
160158
spliced_body = splice_body(result.headers, result.body)

lua/rest-nvim/request/init.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ local function get_importfile_name(bufnr, start_line, stop_line)
2222
fileimport_line = vim.api.nvim_buf_get_lines(bufnr, import_line - 1, import_line, false)
2323
-- check second char against '@' (meaning "dont inline")
2424
fileimport_inlined = string.sub(fileimport_line[1], 2, 2) ~= "@"
25-
fileimport_string =
26-
string.gsub(fileimport_line[1], "<@?", "", 1):gsub("^%s+", ""):gsub("%s+$", "")
25+
fileimport_string = string.gsub(fileimport_line[1], "<@?", "", 1):gsub("^%s+", ""):gsub("%s+$", "")
2726
return fileimport_inlined, fileimport_string
2827
end
2928
return nil
@@ -285,7 +284,7 @@ M.buf_get_request = function(bufnr, curpos)
285284

286285
local curl_args, body_start = get_curl_args(bufnr, headers_end, end_line)
287286

288-
local host = utils.get_value(headers, "host") or ""
287+
local host = headers[utils.key(headers, "host")] or ""
289288
parsed_url.url = host:gsub("%s+", "") .. parsed_url.url
290289
headers[utils.key(headers, "host")] = nil
291290

lua/rest-nvim/utils/init.lua

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,16 +317,6 @@ M.key = function(tbl, key)
317317
return key
318318
end
319319

320-
--- Get the table value or nil if not found
321-
---
322-
--- @param tbl (table) Table to iterate over
323-
--- @param key (string) The key to the value case insensitive
324-
---
325-
--- @return any
326-
M.get_value = function(tbl, key)
327-
return tbl[M.key(tbl, key)]
328-
end
329-
330320
-- tbl_to_str recursively converts the provided table into a json string
331321
-- @param tbl Table to convert into a String
332322
-- @param json If the string should use a key:value syntax

0 commit comments

Comments
 (0)