Fix transpilers for zoekt filters
What does this MR do and why?
This code refactors how search filters are processed in a search query system. The main changes simplify the code structure by replacing a multi-line case statement with a more concise single-line format, and completely rewrite the filter transformation logic to be more robust.
The new approach processes each filter individually using a mapping function instead of modifying filters in-place. It now properly handles special characters (like dots, asterisks, and question marks) by escaping them to prevent unintended regex behavior, then selectively converts wildcards (* and ?) back to their regex equivalents for pattern matching.
The filter parsing is also improved - it now cleanly separates the negation prefix (-), filter name, and filter value, making the code more readable and maintainable. The transformation logic for different filter types (extension, filename, path) has been updated to use the new escaped values.
The test cases reflect these improvements, showing that the system now correctly handles more complex scenarios like filenames with dots, wildcards, and mixed special characters, ensuring search queries work as expected without breaking due to unescaped regex characters.
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.