diff --git a/Modules/Bar/Widgets/Tray.qml b/Modules/Bar/Widgets/Tray.qml index 8361a1d6..88bd9f6b 100644 --- a/Modules/Bar/Widgets/Tray.qml +++ b/Modules/Bar/Widgets/Tray.qml @@ -41,7 +41,28 @@ Rectangle { property var filteredItems: [] function wildCardMatch(str, rule) { - return str.toLowerCase().includes(rule.toLowerCase()); // Simple substring match + if (!str || !rule) { + return false; + } + Logger.log("Tray", "wildCardMatch - Input str:", str, "rule:", rule); + + // Escape all special regex characters in the rule + let escapedRule = rule.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + // Convert '*' to '.*' for wildcard matching + let pattern = escapedRule.replace(/\\\*/g, '.*'); + // Add ^ and $ to match the entire string + pattern = '^' + pattern + '$'; + + Logger.log("Tray", "wildCardMatch - Generated pattern:", pattern); + + try { + const regex = new RegExp(pattern, 'i'); // 'i' for case-insensitive + Logger.log("Tray", "wildCardMatch - Regex test result:", regex.test(str)); + return regex.test(str); + } catch (e) { + Logger.warn("Tray", "Invalid regex pattern for wildcard match:", rule, e.message); + return false; // If regex is invalid, it won't match + } } function updateFilteredItems() {