Skip to content

Commit

Permalink
fix: proper comments parsing regex. Closes #29
Browse files Browse the repository at this point in the history
  • Loading branch information
NTBBloodbath committed Jun 30, 2021
1 parent 850f01e commit fb35b85
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/rest-nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ local function get_body(bufnr, stop_line, query_line, json_body)
)

for _, json_line in ipairs(json_lines) do
if not json_line:find('^%s+#') then
-- Ignore commented lines with and without indent
if not (json_line:find('^#') or json_line:find('^%s+#')) then
json_string = json_string .. utils.replace_env_vars(json_line)
end
end
Expand Down Expand Up @@ -147,7 +148,7 @@ local function get_headers(bufnr, query_line)
and not header[1]:find('^%s+"')
-- If header key doesn't contains hashes,
-- so we don't get commented headers
and not header[1]:find('^%s+#')
and not (header[1]:find('^#') or header[1]:find('^%s+#'))
-- If header key doesn't contains HTTP methods,
-- so we don't get the http method/url
and not utils.has_value(http_methods, header[1])
Expand Down Expand Up @@ -186,7 +187,8 @@ local function get_accept(bufnr, query_line)
)

for _, accept_data in pairs(accept_line) do
if not accept_data:find('^%s+#') then
-- Ignore commented lines with and without indent
if not (accept_data:find('^#') or accept_data:find('(^%s+#)')) then
accept = utils.split(accept_data, ':')[2]
end
end
Expand Down

0 comments on commit fb35b85

Please sign in to comment.