Skip to content

Commit

Permalink
feat(RL-76): search is now exact
Browse files Browse the repository at this point in the history
  • Loading branch information
NoodleOfDeath committed Oct 16, 2023
1 parent df5dab1 commit 964dc76
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function parseTimeInterval(str: string) {

function buildFilter(
filter = '',
matchType: 'any' | 'exact' = 'exact',
matchType: 'any' | 'exact' = 'exact'
) {
const categories: string[] = [];
const excludedCategories: string[] = [];
Expand Down Expand Up @@ -144,7 +144,7 @@ function buildFilter(
.replace(/\s\s+/g, ' ')
.replace(/[-+*|=<>.^$!?(){}[\]\\]/g, ($0) => `\\${$0}`);
if (matchType === 'exact') {
parts.push(`(?:(?:^|\\y)${query.replace(/['"]/g, ($0) => `\\${$0}`))}(?:\\y|$))`);
parts.push(`(?:(?:^|\\y)${query.replace(/['"]/g, ($0) => `\\${$0}`)}(?:\\y|$))`);
} else {
const matches = query.matchAll(/(['"])(.+?)\1|\b([\S]+)\b/gm);
if (matches) {
Expand All @@ -158,7 +158,7 @@ function buildFilter(
categories,
excludedCategories,
excludedPublishers,
filter: regex,
filter: regex.length > 2 ? regex : '',
interval,
publishers,
};
Expand Down

0 comments on commit 964dc76

Please sign in to comment.