From 91badd46c60df6bd9800c809056af2d80d33da4c Mon Sep 17 00:00:00 2001 From: Gabriel Salas Date: Fri, 15 Mar 2024 03:29:19 -0300 Subject: [PATCH] fix: get json content type for custom content types (#297) --- lua/rest-nvim/curl/init.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/rest-nvim/curl/init.lua b/lua/rest-nvim/curl/init.lua index 06dff77c..1d7f04bb 100644 --- a/lua/rest-nvim/curl/init.lua +++ b/lua/rest-nvim/curl/init.lua @@ -133,7 +133,13 @@ local function create_callback(curl_cmd, opts) local content_type = res.headers[utils.key(res.headers, "content-type")] if content_type then - content_type = content_type:match("application/([-a-z]+)") or content_type:match("text/(%l+)") + local isJson = content_type:match("application/.+(json)") + + if isJson then + content_type = "json" + else + content_type = content_type:match("application/([-a-z]+)") or content_type:match("text/(%l+)") + end end if script_str ~= nil then