mirror of
https://github.com/umami-software/umami.git
synced 2026-02-21 04:55:36 +01:00
Allow * as wildcard in filter, re #2070
No UI but edit the URL to provide a filter with * in it and the query gets changed to LIKE and the * to %. Works in MySQL at least! fix regex
This commit is contained in:
parent
71bb012cab
commit
2257ad7b70
1 changed files with 9 additions and 2 deletions
|
|
@ -111,9 +111,16 @@ function getFilterQuery(filters = {}, params = []): string {
|
||||||
const filter = filters[key];
|
const filter = filters[key];
|
||||||
|
|
||||||
if (filter !== undefined) {
|
if (filter !== undefined) {
|
||||||
|
let filterValue = decodeURIComponent(filter),
|
||||||
|
op = '=';
|
||||||
const column = FILTER_COLUMNS[key] || key;
|
const column = FILTER_COLUMNS[key] || key;
|
||||||
arr.push(`and ${column}=$${params.length + 1}`);
|
|
||||||
params.push(decodeURIComponent(filter));
|
if (filterValue.indexOf('*') > -1) {
|
||||||
|
op = 'LIKE';
|
||||||
|
filterValue = filterValue.replaceAll(/\*+/g, '%');
|
||||||
|
}
|
||||||
|
arr.push(`and ${column} ${op} $${params.length + 1}`);
|
||||||
|
params.push(filterValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue