Skip to content

Commit 0e3d24c

Browse files
committed
keyword search case insensitive
1 parent 53050fa commit 0e3d24c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function formatMessage(string, keywords)
4646
const urlRegex = /(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))/g;
4747
s = s.replace(urlRegex, (match, p1) => `<a href="${p1}">${p1}</a>`);
4848

49-
keywords.filter(word => word.length).forEach(word => s = s.replace(new RegExp(word, "g"), `<span class="keyword">${word}</span>`));
49+
keywords.filter(word => word.length).forEach(word => s = s.replace(new RegExp(`(${word})`, "gi"), (match, p1) => `<span class="keyword">${p1}</span>`));
5050
return s;
5151
}
5252

@@ -174,7 +174,7 @@ function strtotime(string)
174174

175175
function containsKeywords(string, keywords)
176176
{
177-
return keywords.reduce((acc, word) => word === "" ? acc : acc && (string.indexOf(word) != -1), true);
177+
return keywords.reduce((acc, word) => word === "" ? acc : acc && (string.toLowerCase().indexOf(word.toLowerCase()) != -1), true);
178178
}
179179

180180
// filter messages query

0 commit comments

Comments
 (0)