Mercurial > prosody-hg
comparison util/jsonpointer.lua @ 13883:b713da7527d2
teal: Regenerate Lua files
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 09 May 2025 00:50:36 +0200 |
| parents | 22066b02887f |
| children |
comparison
equal
deleted
inserted
replaced
| 13882:1ff24220fa2c | 13883:b713da7527d2 |
|---|---|
| 1 local m_type = math.type; | 1 -- This file is generated from teal-src/prosody/util/jsonpointer.tl |
| 2 | |
| 3 local function unescape_token(escaped_token) | 2 local function unescape_token(escaped_token) |
| 4 local unescaped = escaped_token:gsub("~1", "/"):gsub("~0", "~") | 3 local unescaped = escaped_token:gsub("~1", "/"):gsub("~0", "~") |
| 5 return unescaped | 4 return unescaped |
| 6 end | 5 end |
| 7 | 6 |
| 15 local idx = next(ref) | 14 local idx = next(ref) |
| 16 local new_ref | 15 local new_ref |
| 17 | 16 |
| 18 if type(idx) == "string" then | 17 if type(idx) == "string" then |
| 19 new_ref = ref[token] | 18 new_ref = ref[token] |
| 20 elseif m_type(idx) == "integer" then | 19 elseif math.type(idx) == "integer" then |
| 21 local i = tonumber(token) | 20 local i = tonumber(token) |
| 22 if token == "-" then | 21 if token == "-" then |
| 23 i = #ref + 1 | 22 i = #(ref) + 1 |
| 24 end | 23 end |
| 25 new_ref = ref[i + 1] | 24 new_ref = ref[i + 1] |
| 26 else | 25 else |
| 27 return nil, "invalid-table" | 26 return nil, "invalid-table" |
| 28 end | 27 end |
