administrate
administrate copied to clipboard
Search filter with special characters
Hi everyone!
- What would you like to be able to do? Can you provide some examples?
If I store some special characters in a column and want to use a filter to search, the search term is not included because of the regexp here. For example in my project I have defined a filter called sender
and an email field that I want to search. If I search sender:test
it works but then when I do it like sender:[email protected]
it does not. Debugging a little I found that line causing the issue.
- How could we go about implementing that?
Changing the regexp to allow more symbols like @
and .
: /^#{filter}:[\w|@|\.]*$/
- Can you think of other approaches to the problem?
It can be simplified as valid_filters&.any? { |filter| word.starts_with?("#{filter}:") }
If you think this approach is fine I can make a PR for it. I monkey patched that class with the first version and its the code I'm currently using.
Regards, Alejandro