Skip to content

Commit

Permalink
Merge branch 'feat-filter-script' into yuriha-master
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriha-chan committed Feb 21, 2024
2 parents f8a3e4e + aa6b063 commit 7138e2a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/backend/src/core/UtilityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export class UtilityService {
@bindThis
public isKeyWordIncluded(keyWords: string[], text: string, cw: string, pollChoices: string | '', files: string[] | []): boolean {
if (keyWords.length === 0) return false;
if (text === '' && cw === '' && files === []) {
return false;
}

const textAndChoices = pollChoices === '' ? text : text + '\n' + pollChoices;

Expand All @@ -58,7 +61,7 @@ export class UtilityService {
const apply = function(node, testText) {
try {
switch (node[0]) {
case "keyword": return testText.includes(node[1]);
case "keyword": return testText.includes && testText.includes(node[1]);
case "regexp": return new RE2(node[1], node[2]).test(testText);
case "slowRegexp": return new RegExp(node[1], node[2]).test(testText);
case "and": return node.slice(1).every(n => apply(n, testText));
Expand All @@ -85,7 +88,7 @@ export class UtilityService {
return parseFilter(filter);
} catch (err) {
// empty filter
return ["and"];
return ["or"];
}
});
try {
Expand Down

0 comments on commit 7138e2a

Please sign in to comment.