shop nil checks
This commit is contained in:
@@ -18,7 +18,9 @@ end
|
|||||||
|
|
||||||
local function findID(url)
|
local function findID(url)
|
||||||
local found = gfind(url, idPatt)
|
local found = gfind(url, idPatt)
|
||||||
return tonumber(found[#found]:sub(found[#found]:find("%d+")))
|
if found then
|
||||||
|
return tonumber(found[#found]:sub(found[#found]:find("%d+")))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function newID()
|
local function newID()
|
||||||
@@ -42,7 +44,7 @@ function init(jua)
|
|||||||
jua = jua
|
jua = jua
|
||||||
jua.on("http_success", function(event, url, handle)
|
jua.on("http_success", function(event, url, handle)
|
||||||
local id = findID(url)
|
local id = findID(url)
|
||||||
if callbackRegistry[id] then
|
if id and callbackRegistry[id] then
|
||||||
callbackRegistry[id](true, trimID(url), handle)
|
callbackRegistry[id](true, trimID(url), handle)
|
||||||
table.remove(callbackRegistry, id)
|
table.remove(callbackRegistry, id)
|
||||||
end
|
end
|
||||||
@@ -50,7 +52,7 @@ function init(jua)
|
|||||||
|
|
||||||
jua.on("http_failure", function(event, url, handle)
|
jua.on("http_failure", function(event, url, handle)
|
||||||
local id = findID(url)
|
local id = findID(url)
|
||||||
if callbackRegistry[id] then
|
if id and callbackRegistry[id] then
|
||||||
callbackRegistry[id](false, trimID(url), handle)
|
callbackRegistry[id](false, trimID(url), handle)
|
||||||
table.remove(callbackRegistry, id)
|
table.remove(callbackRegistry, id)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user