Fixed regex for filter params.

This commit is contained in:
Mike Cao
2025-10-10 11:33:13 -07:00
parent ac9edb8b5f
commit 53929626cf

View File

@@ -3,10 +3,15 @@ import { Filter, QueryFilters, QueryOptions } from '@/lib/types';
export function parseFilterValue(param: any) {
if (typeof param === 'string') {
const [, operator, value] = param.match(/^([a-z]+)\.(.*)/) || [];
const operatorValues = Object.values(OPERATORS).join('|');
const regex = new RegExp(`^(${operatorValues})\\.(.*)$`);
const [, operator, value] = param.match(regex) || [];
return { operator: operator || OPERATORS.equals, value: value || param };
}
return { operator: OPERATORS.equals, value: param };
}