aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-05-09 22:36:57 +0200
committerKim Alvefur <zash@zash.se>2022-05-09 22:36:57 +0200
commitd9de9b5627a4cce0fcad27ecc39ce62a9176b3b8 (patch)
tree98dc2f280e8eb81603bc35a49f911bbaeeb6fff7 /util
parentd05af9f2b54d292b49b694d8317152f4339f7076 (diff)
downloadprosody-d9de9b5627a4cce0fcad27ecc39ce62a9176b3b8.tar.gz
prosody-d9de9b5627a4cce0fcad27ecc39ce62a9176b3b8.zip
util.jsonpointer: Fix Lua <5.3 compat
Diffstat (limited to 'util')
-rw-r--r--util/jsonpointer.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/util/jsonpointer.lua b/util/jsonpointer.lua
index dd5ac9d6..9b871ae7 100644
--- a/util/jsonpointer.lua
+++ b/util/jsonpointer.lua
@@ -1,3 +1,7 @@
+local m_type = math.type or function (n)
+ return n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float";
+end;
+
local function unescape_token(escaped_token)
local unescaped = escaped_token:gsub("~1", "/"):gsub("~0", "~")
return unescaped
@@ -15,7 +19,7 @@ local function resolve_json_pointer(ref, path)
if type(idx) == "string" then
new_ref = ref[token]
- elseif math.type(idx) == "integer" then
+ elseif m_type(idx) == "integer" then
local i = tonumber(token)
if token == "-" then
i = #ref + 1