Skip to content

Commit 62606c3

Browse files
fix: correct uri scheme parsing
1 parent 5455092 commit 62606c3

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lua/rest-nvim/client/curl_cli.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local curl_cli = require("rest-nvim.client.curl.cli")
2+
local logger = require("rest-nvim.logger")
23

34
local COMPATIBLE_METHODS = {
45
"OPTIONS",
@@ -20,8 +21,9 @@ local client = {
2021
request = curl_cli.request,
2122
available = function(req)
2223
local method_ok = vim.list_contains(COMPATIBLE_METHODS, req.method)
23-
local scheme = req.url:match("^(.+)://")
24+
local scheme = req.url:match("^([^:]+)://")
2425
local scheme_ok = (not scheme) or scheme == "http" or scheme == "https"
26+
logger.debug(("scheme %s not supported for curl_cli client"):format(scheme or "<nil>"))
2527
return method_ok and scheme_ok
2628
end,
2729
}

spec/client/client_spec.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---@module 'luassert'
2+
3+
local clients = require("rest-nvim.client")
4+
5+
describe("request clients", function()
6+
it("get_available_clients", function()
7+
local req = {
8+
method = "GET",
9+
url = "https://duckduckgo.com?q=https://duckduckgo.com",
10+
headers = {},
11+
cookies = {},
12+
handlers = {},
13+
}
14+
local available_clients = clients.get_available_clients(req)
15+
assert.same(1, #available_clients)
16+
end)
17+
end)

0 commit comments

Comments
 (0)