Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Fixed regex for filter params.

Mike Cao53929626cf73
diff --git a/src/lib/params.ts b/src/lib/params.ts
index 71fd8cb22..7f383a2ef 100644
--- a/src/lib/params.ts
+++ b/src/lib/params.ts
@@ -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 };
}