diff --git a/lua/plenary/curl.lua b/lua/plenary/curl.lua index b7fc9974..5e9561d8 100644 --- a/lua/plenary/curl.lua +++ b/lua/plenary/curl.lua @@ -322,9 +322,9 @@ end -- Main ---------------------------------------------------- ------------------------------------------------------------ return (function() - local spec = {} local partial = function(method) return function(url, opts) + local spec = {} opts = opts or {} if type(url) == "table" then opts = url diff --git a/tests/plenary/curl_spec.lua b/tests/plenary/curl_spec.lua index c268492f..c4ba89aa 100644 --- a/tests/plenary/curl_spec.lua +++ b/tests/plenary/curl_spec.lua @@ -196,10 +196,26 @@ describe("CURL Wrapper:", function() end) end) - describe("DEPUG", function() -------------------------------------------------- + describe("DEBUG", function() -------------------------------------------------- it("dry_run return the curl command to be ran.", function() local res = curl.delete("https://jsonplaceholder.typicode.com/posts/8", { dry_run = true }) assert(type(res) == "table") end) end) + + describe("Issue #601", function() -------------------------------------------- + it("should not use URL from previous call", function() + local url = "https://example.com" + local opts = { dry_run = true, dump = "" } -- dump would be random each time + local first = curl.get(url, opts) + eq(table.remove(first, #first), url, "expected url last") + + local success, second = pcall(curl.get, opts) + if success then + eq(first, second, "should be same, but without url") + else + -- Failure is also acceptable + end + end) + end) end)