From 9921ede8fa4b782a143cb993fe352161d32c123f Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Sat, 12 Jan 2019 09:12:52 -0500 Subject: [PATCH] shop nil checks --- swshop/r.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/swshop/r.lua b/swshop/r.lua index b13062e..5718be4 100644 --- a/swshop/r.lua +++ b/swshop/r.lua @@ -18,7 +18,9 @@ end local function findID(url) 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 local function newID() @@ -42,7 +44,7 @@ function init(jua) jua = jua jua.on("http_success", function(event, url, handle) local id = findID(url) - if callbackRegistry[id] then + if id and callbackRegistry[id] then callbackRegistry[id](true, trimID(url), handle) table.remove(callbackRegistry, id) end @@ -50,7 +52,7 @@ function init(jua) jua.on("http_failure", function(event, url, handle) local id = findID(url) - if callbackRegistry[id] then + if id and callbackRegistry[id] then callbackRegistry[id](false, trimID(url), handle) table.remove(callbackRegistry, id) end