Skip to content

Commit

Permalink
standardised search behaviour with help text
Browse files Browse the repository at this point in the history
  • Loading branch information
bobular committed Nov 1, 2024
1 parent 564f453 commit 6907790
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import {
import { RecordTable_TaxonCounts_Filter } from './RecordTable_TaxonCounts_Filter';
import { formatAttributeValue } from '@veupathdb/wdk-client/lib/Utils/ComponentUtils';
import { RecordFilter } from '@veupathdb/wdk-client/lib/Views/Records/RecordTable/RecordFilter';
import {
areTermsInStringRegexString,
parseSearchQueryString,
} from '../../../../../../../libs/wdk-client/lib/Utils/SearchUtils';

type RowType = Record<string, AttributeValue>;

Expand Down Expand Up @@ -800,14 +804,9 @@ function rowMatch(row: RowType, query: RegExp, keys?: string[]): boolean {

function createSafeSearchRegExp(input: string): RegExp | undefined {
if (input === '') return undefined;
try {
// Attempt to create a RegExp from the user input directly
return new RegExp(input, 'i');
} catch (error) {
// If an error occurs (e.g., invalid RegExp), escape the input and create a literal search RegExp
const escapedInput = input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
return new RegExp(escapedInput, 'i');
}
const queryTerms = parseSearchQueryString(input);
const searchTermRegex = areTermsInStringRegexString(queryTerms);
return new RegExp(searchTermRegex, 'i');
}

function logIdMismatches(A: string[], B: string[]) {
Expand Down

0 comments on commit 6907790

Please sign in to comment.