From 929c1ea9ae59fda3f8429601bfe1f59250f01632 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Sun, 24 Sep 2017 14:02:42 +0100 Subject: [PATCH] fixed null handling for regex matching --- app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 0cc5ea2..409965c 100644 --- a/app.js +++ b/app.js @@ -653,7 +653,7 @@ const doSendTip = (body, message, callback) => { let amountLbc = 0; let matchedString = ''; const match = String(message.data.body).match(tipRegex); - if (match.length > 0) { + if (match && match.length > 0) { matchedString = match[0]; if (matchedString.indexOf(' ') > -1) { const parts = matchedString.split(' ', 2); @@ -940,7 +940,8 @@ const processMessage = function(message, callback) { } if (message.kind === commentKind) { - if (body.match(gildRegex).length > 0) { + const gildMatch = body.match(gildRegex); + if (gildMatch && gildMatch.length > 0) { doGild(message, callback); } else { doSendTip(body, message, callback);