From 0d4ad2f07541589368943d73c51b0bdfea71dc93 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 23 Aug 2019 13:51:01 +0200 Subject: [PATCH] Fix global leaks detected by mocha Fix globals leaked in stringUtils, isJson and static/nav.html. --- lib/stringUtils.js | 3 +-- sharedPlugins/inventoryImports/isJson.js | 2 +- static/nav.html | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/stringUtils.js b/lib/stringUtils.js index f6f591c3..7febd82b 100644 --- a/lib/stringUtils.js +++ b/lib/stringUtils.js @@ -3,8 +3,7 @@ function hashCode(string){ var hash = 0; if (string.length == 0) return hash; for (let i = 0; i < string.length; i++) { - char = string.charCodeAt(i); - hash = ((hash << 5) - hash) + char; + hash = ((hash << 5) - hash) + string.charCodeAt(i); hash = hash & hash; // Convert to 32bit integer } return hash; diff --git a/sharedPlugins/inventoryImports/isJson.js b/sharedPlugins/inventoryImports/isJson.js index 597564df..c0a1b3c1 100644 --- a/sharedPlugins/inventoryImports/isJson.js +++ b/sharedPlugins/inventoryImports/isJson.js @@ -2,7 +2,7 @@ module.exports = function(x){ if(x === false || x === true || x === null) return true; // === false is valid JSON, so is true and null var isNotJson = false try{ - z = JSON.parse(x); + JSON.parse(x); } catch (e) { isNotJson = true; } diff --git a/static/nav.html b/static/nav.html index 0787e5d6..6c359198 100644 --- a/static/nav.html +++ b/static/nav.html @@ -13,7 +13,7 @@ <%# Very ugly ejs code to hide the Players button if the playerManager plugin isn`t installed %> <% - sidebarPluginButtonsHtml = ""; + let sidebarPluginButtonsHtml = ""; for(let o in locals.masterPlugins){ let plug = locals.masterPlugins[o]; if(plug.main