diff --git a/lua/gemini/api.lua b/lua/gemini/api.lua index a9da6d8..687d093 100644 --- a/lua/gemini/api.lua +++ b/lua/gemini/api.lua @@ -12,7 +12,17 @@ end -- Async HTTP request function 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() client:connect(host, 443, function(err) @@ -33,7 +43,7 @@ local function async_request(url, payload, callback) "Content-Length: %d\r\n" .. "\r\n" .. "%s", - port, host, #payload, payload + path, host, #payload, payload ) local response = ""