Skip to content

Commit 91badd4

Browse files
authored
fix: get json content type for custom content types (#297)
1 parent 1ddcc92 commit 91badd4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/rest-nvim/curl/init.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,13 @@ local function create_callback(curl_cmd, opts)
133133

134134
local content_type = res.headers[utils.key(res.headers, "content-type")]
135135
if content_type then
136-
content_type = content_type:match("application/([-a-z]+)") or content_type:match("text/(%l+)")
136+
local isJson = content_type:match("application/.+(json)")
137+
138+
if isJson then
139+
content_type = "json"
140+
else
141+
content_type = content_type:match("application/([-a-z]+)") or content_type:match("text/(%l+)")
142+
end
137143
end
138144

139145
if script_str ~= nil then

0 commit comments

Comments
 (0)