From 9d70400a30047f4c3335e7057864edc5ca7fa4f5 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 5 Aug 2022 13:01:08 +0300 Subject: [PATCH] bugfix? --- src/utilities/FilterUtil.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/utilities/FilterUtil.js b/src/utilities/FilterUtil.js index c0179bb..cb849cd 100644 --- a/src/utilities/FilterUtil.js +++ b/src/utilities/FilterUtil.js @@ -274,18 +274,20 @@ module.exports = class FilterUtility { //log += `\next reg: ${tmp}`; const fullWord = words.find((word) => word.includes(match[1])); - let inWL = false; - try { // This is for debugging only - inWL = FilterUtility.whitelist.find(fullWord); - } catch (err) { - this.logger.error(`Whitelist.find error: ${fullWord} ${match[1]} ${words}`); - } - if (inWL || whitelist.some((word) => word === fullWord)) continue; + if(fullWord) { + let inWL = false; + try { // This is for debugging only + inWL = FilterUtility.whitelist.find(fullWord); + } catch (err) { + this.logger.error(`Whitelist.find error: ${fullWord} ${match[1]} ${words}`); + } + if (inWL || whitelist.some((word) => word === fullWord)) continue; - const diff = Math.abs(fullWord.length - match[0].length); - if (diff > 3) { - this.logger.debug(`Match length diff: ${diff} MATCH: ${match[0]} FULL: ${fullWord}, CONTENT: ${content}`); - continue; + const diff = Math.abs(fullWord.length - match[0].length); + if (diff > 3) { + this.logger.debug(`Match length diff: ${diff} MATCH: ${match[0]} FULL: ${fullWord}, CONTENT: ${content}`); + continue; + } } // log += `\nMessage matched with "${reg}" in the regex list.\nMatch: ${match[0]}, Full word: ${fullWord}\nFull content: ${content}`; return {