util.jsonpointer: Fix off-by-one in array resolution

Fixes #1753

Not known to be used anywhere
This commit is contained in:
Kim Alvefur 2022-05-08 18:04:50 +02:00
parent 11638f57e2
commit d05af9f2b5
2 changed files with 2 additions and 2 deletions

View file

@ -24,7 +24,7 @@ local function resolve_json_pointer(ref : table, path : string) : any, ptr_error
elseif idx is integer then
local i = tonumber(token)
if token == "-" then i = #ref + 1 end
new_ref = ref[i]
new_ref = ref[i+1]
else
return nil, "invalid-table"
end

View file

@ -20,7 +20,7 @@ local function resolve_json_pointer(ref, path)
if token == "-" then
i = #ref + 1
end
new_ref = ref[i]
new_ref = ref[i + 1]
else
return nil, "invalid-table"
end