fixed null handling for regex matching
This commit is contained in:
parent
7d92f29676
commit
929c1ea9ae
1 changed files with 3 additions and 2 deletions
5
app.js
5
app.js
|
@ -653,7 +653,7 @@ const doSendTip = (body, message, callback) => {
|
||||||
let amountLbc = 0;
|
let amountLbc = 0;
|
||||||
let matchedString = '';
|
let matchedString = '';
|
||||||
const match = String(message.data.body).match(tipRegex);
|
const match = String(message.data.body).match(tipRegex);
|
||||||
if (match.length > 0) {
|
if (match && match.length > 0) {
|
||||||
matchedString = match[0];
|
matchedString = match[0];
|
||||||
if (matchedString.indexOf(' ') > -1) {
|
if (matchedString.indexOf(' ') > -1) {
|
||||||
const parts = matchedString.split(' ', 2);
|
const parts = matchedString.split(' ', 2);
|
||||||
|
@ -940,7 +940,8 @@ const processMessage = function(message, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.kind === commentKind) {
|
if (message.kind === commentKind) {
|
||||||
if (body.match(gildRegex).length > 0) {
|
const gildMatch = body.match(gildRegex);
|
||||||
|
if (gildMatch && gildMatch.length > 0) {
|
||||||
doGild(message, callback);
|
doGild(message, callback);
|
||||||
} else {
|
} else {
|
||||||
doSendTip(body, message, callback);
|
doSendTip(body, message, callback);
|
||||||
|
|
Loading…
Reference in a new issue