Skip to content

Commit a6decd3

Browse files
committed
refact: better comments detection
1 parent 0096462 commit a6decd3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lua/rest-nvim/init.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ local function get_body(bufnr, stop_line, query_line, json_body)
8484
)
8585

8686
for _, json_line in ipairs(json_lines) do
87-
if json_line:find('^#') == nil then
87+
if json_line:find('^%s+#') == nil then
8888
json_string = json_string .. utils.replace_env_vars(json_line)
8989
end
9090
end
@@ -147,7 +147,7 @@ local function get_headers(bufnr, query_line)
147147
and header[1]:find('"') == nil
148148
-- If header key doesn't contains hashes,
149149
-- so we don't get commented headers
150-
and header[1]:find('^#') == nil
150+
and header[1]:find('^%s+#') == nil
151151
-- If header key doesn't contains HTTP methods,
152152
-- so we don't get the http method/url
153153
and not utils.has_value(http_methods, header[1])
@@ -184,7 +184,7 @@ local function get_accept(bufnr, query_line)
184184
)
185185

186186
for _, accept_data in pairs(accept_line) do
187-
if accept_data:find('^#') == nil then
187+
if accept_data:find('^%s+#') == nil then
188188
accept = utils.split(accept_data, ':')[2]
189189
end
190190
end
@@ -217,7 +217,7 @@ local function get_auth(bufnr, query_line)
217217
)
218218

219219
for _, auth_data in pairs(auth_line) do
220-
if auth_data:find('^#') == nil then
220+
if auth_data:find('^%s+#') == nil then
221221
-- Split by spaces, e.g. {'Authorization:', 'user:pass'}
222222
auth_data = utils.split(auth_data, '%s+')
223223
-- {'user', 'pass'}

0 commit comments

Comments
 (0)