mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Fixed regex for filter params.
This commit is contained in:
parent
ac9edb8b5f
commit
53929626cf
1 changed files with 6 additions and 1 deletions
|
|
@ -3,10 +3,15 @@ import { Filter, QueryFilters, QueryOptions } from '@/lib/types';
|
||||||
|
|
||||||
export function parseFilterValue(param: any) {
|
export function parseFilterValue(param: any) {
|
||||||
if (typeof param === 'string') {
|
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: operator || OPERATORS.equals, value: value || param };
|
||||||
}
|
}
|
||||||
|
|
||||||
return { operator: OPERATORS.equals, value: param };
|
return { operator: OPERATORS.equals, value: param };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue