Fixed crash

This commit is contained in:
Jonas Widen 2025-03-16 18:33:46 +01:00
parent 9054ba178f
commit 6a3d484486

View File

@ -12,7 +12,17 @@ end
-- Async HTTP request function -- Async HTTP request function
local function async_request(url, payload, callback) local function async_request(url, payload, callback)
local host, port = vim.uri_from_fname(url):match("^https://([^/]+)(/.*)$") -- Parse URL properly
local host = url:match("^https://([^/]+)")
local path = url:match("^https://[^/]+(.*)$")
if not host or not path then
vim.schedule(function()
callback(nil, "Invalid URL format")
end)
return
end
local client = vim.loop.new_tcp() local client = vim.loop.new_tcp()
client:connect(host, 443, function(err) client:connect(host, 443, function(err)
@ -33,7 +43,7 @@ local function async_request(url, payload, callback)
"Content-Length: %d\r\n" .. "Content-Length: %d\r\n" ..
"\r\n" .. "\r\n" ..
"%s", "%s",
port, host, #payload, payload path, host, #payload, payload
) )
local response = "" local response = ""