Filter tag enhancements.

This commit is contained in:
Mike Cao 2024-04-01 10:10:56 -07:00
parent a4d8afe516
commit ef11124672
12 changed files with 160 additions and 64 deletions

15
src/lib/params.ts Normal file
View file

@ -0,0 +1,15 @@
import { OPERATOR_PREFIXES, OPERATORS } from 'lib/constants';
export function parseParameterValue(param: string) {
const [, prefix, value] = param.match(/^(!~|!|~)?(.*)$/);
const operator =
Object.keys(OPERATOR_PREFIXES).find(key => OPERATOR_PREFIXES[key] === prefix) ||
OPERATORS.equals;
return { operator, value };
}
export function operatorEquals(operator: any) {
return [OPERATORS.equals, OPERATORS.notEquals].includes(operator);
}