···
.filter((f) => f.length > 0);
92
-
const exclusions: string[] = [];
93
-
const inclusions: string[] = [];
92
+
const exclusions: { pattern: string; hasWildcard: boolean }[] = [];
93
+
const inclusions: { pattern: string; hasWildcard: boolean }[] = [];
97
-
exclusions.push(f.slice(1).toLowerCase());
97
+
const lower = f.slice(1).toLowerCase();
100
+
hasWildcard: lower.includes("*"),
99
-
inclusions.push(f.toLowerCase());
103
+
const lower = f.toLowerCase();
106
+
hasWildcard: lower.includes("*"),
111
+
const matchesPattern = (value: string, filter: { pattern: string; hasWildcard: boolean }) => {
112
+
if (filter.hasWildcard) {
113
+
// Convert wildcard pattern to regex
114
+
const regexPattern = filter.pattern
115
+
.replace(/[.+?^${}()|[\]\\]/g, "\\$&") // Escape special regex chars except *
116
+
.replace(/\*/g, ".*"); // Replace * with .*
117
+
const regex = new RegExp(`^${regexPattern}$`);
118
+
return regex.test(value);
120
+
return value === filter.pattern;
return labels().filter((label) => {
const labelValue = label.val.toLowerCase();
106
-
// Check exclusions (exact match)
107
-
if (exclusions.some((exc) => labelValue === exc)) {
127
+
if (exclusions.some((exc) => matchesPattern(labelValue, exc))) {
111
-
// If there are inclusions, at least one must match (partial match)
131
+
// If there are inclusions, at least one must match
if (inclusions.length > 0) {
113
-
return inclusions.some((inc) => labelValue.includes(inc));
133
+
return inclusions.some((inc) => matchesPattern(labelValue, inc));
// If only exclusions were specified, include everything not excluded
···
<div class="flex w-full items-center gap-x-2">
250
-
placeholder="Filter labels (space separated, -label to exclude)"
270
+
placeholder="Filter labels (* for partial, -exclude)"
onInput={(e) => setFilter(e.currentTarget.value)}