Skip to content

Commit 9800b59

Browse files
MatsuuuNTBBloodbath
authored andcommitted
Allow spaces in variable names, and cross compat
1 parent 1d76b3a commit 9800b59

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lua/rest-nvim/request/init.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,14 @@ end
161161
-- @param stmt the request statement, e.g., POST http://localhost:3000/foo
162162
local function parse_url(stmt)
163163
local parsed = utils.split(stmt, " ")
164+
local http_method = parsed[1]
165+
table.remove(parsed, 1)
166+
local target_url = table.concat(parsed, " ")
167+
164168
return {
165-
method = parsed[1],
169+
method = http_method,
166170
-- Encode URL
167-
url = utils.encode_url(utils.replace_vars(parsed[2])),
171+
url = utils.encode_url(utils.replace_vars(target_url)),
168172
}
169173
end
170174

lua/rest-nvim/utils/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ end
140140
-- @param str Where replace the placers for the env variables
141141
M.replace_vars = function(str)
142142
local vars = M.read_variables()
143+
-- remove $dotenv tags, which are used by the vscode rest client for cross compatibility
144+
str = str:gsub("%$dotenv ", ""):gsub("%$DOTENV ", "")
143145

144146
for var in string.gmatch(str, "{{[^}]+}}") do
145147
var = var:gsub("{", ""):gsub("}", "")

0 commit comments

Comments
 (0)