rest-nvim / rest.nvim

A fast Neovim http client written in Lua
GNU General Public License v3.0
1.61k stars 142 forks source link

Query string array syntax error #347

Closed Rasmus-Bertell closed 7 months ago

Rasmus-Bertell commented 7 months ago

There seems to be some sort of problem handling arrays in url parameters

[!NOTE]

I had to disable the encode_url option to get url parameters to work, since otherwise it encodes the = #317

request.http

GET http://localhost:8000/api/v1/areas?search[available]=1
Accept: application/json

log

[rest.nvim] ERROR: The tree-sitter node at the range [0:46 - 58] has a syntax error and cannot be parsed
[rest.nvim] ERROR: The tree-sitter node at the range [0:46 - 58] has a syntax error and cannot be parsed
Error executing Lua callback: .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:114: attempt to index local 'req_node' (a nil value)
stack traceback:
    .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:114: in function 'traverse_request'
    .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:432: in function 'parse'
    ...al/share/nvim/lazy/rest.nvim/lua/rest-nvim/functions.lua:61: in function 'exec'
    ...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:44: in function 'impl'
    ...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:182: in function <...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:165>
PedroAmLemos commented 7 months ago

I have the same problem with:

GET http://localhost:8080/endpoint/positions?datainicio=2023-04-28T00:00:00&datafim=2024-05-01T23:59:59&manifesto=3&placa=DPC-4026

Using TSPlaygroundToggle shows:

request [0, 0] - [2, 0]
  method [0, 0] - [0, 3]
  target_url [0, 4] - [0, 135]
    scheme [0, 4] - [0, 8]
    host [0, 11] - [0, 25]
      identifier [0, 11] - [0, 20]
      port [0, 20] - [0, 25]
    path [0, 25] - [0, 49]
      identifier [0, 26] - [0, 40]
      identifier [0, 41] - [0, 49]
    query_param [0, 50] - [0, 74]
      key: key [0, 50] - [0, 60]
      value: value [0, 61] - [0, 74]
    ERROR [0, 74] - [0, 80]
    query_param [0, 80] - [0, 102]
      key: key [0, 81] - [0, 88]
      value: value [0, 89] - [0, 102]
    ERROR [0, 102] - [0, 108]
    query_param [0, 108] - [0, 120]
      key: key [0, 109] - [0, 118]
      value: value [0, 119] - [0, 120]
    query_param [0, 120] - [0, 135]
      key: key [0, 121] - [0, 126]
      value: value [0, 127] - [0, 135]
  header [1, 0] - [2, 0]
    name: name [1, 0] - [1, 5]
    value: value [1, 6] - [2, 0]

The ERROR is defined in :00:00 and :59:59

Using this config does not solve

require("rest-nvim").setup({
    encode_url = true,
  })

Any workarounds?