Skip to content

Commit 0096462

Browse files
committed
fix: ignore commented lines as it should be
1 parent f04b205 commit 0096462

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

lua/rest-nvim/init.lua

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ local function get_body(bufnr, stop_line, query_line, json_body)
8383
false
8484
)
8585

86-
for _, v in ipairs(json_lines) do
87-
json_string = json_string .. utils.replace_env_vars(v)
86+
for _, json_line in ipairs(json_lines) do
87+
if json_line:find('^#') == nil then
88+
json_string = json_string .. utils.replace_env_vars(json_line)
89+
end
8890
end
8991

9092
json_string = '{' .. json_string .. '}'
@@ -182,7 +184,9 @@ local function get_accept(bufnr, query_line)
182184
)
183185

184186
for _, accept_data in pairs(accept_line) do
185-
accept = utils.split(accept_data, ':')[2]
187+
if accept_data:find('^#') == nil then
188+
accept = utils.split(accept_data, ':')[2]
189+
end
186190
end
187191
end
188192

@@ -213,10 +217,12 @@ local function get_auth(bufnr, query_line)
213217
)
214218

215219
for _, auth_data in pairs(auth_line) do
216-
-- Split by spaces, e.g. {'Authorization:', 'user:pass'}
217-
auth_data = utils.split(auth_data, '%s+')
218-
-- {'user', 'pass'}
219-
auth = utils.split(utils.replace_env_vars(auth_data[2]), ':')
220+
if auth_data:find('^#') == nil then
221+
-- Split by spaces, e.g. {'Authorization:', 'user:pass'}
222+
auth_data = utils.split(auth_data, '%s+')
223+
-- {'user', 'pass'}
224+
auth = utils.split(utils.replace_env_vars(auth_data[2]), ':')
225+
end
220226
end
221227
end
222228

0 commit comments

Comments
 (0)