mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 13:18:18 +00:00
Use case insensitive regex matching with grep files tool
This commit is contained in:
@@ -1763,7 +1763,7 @@ class FileObjectAdapters:
|
||||
Search for a regex pattern in file objects, with an optional path prefix filter.
|
||||
Outputs results in grep format.
|
||||
"""
|
||||
query = FileObject.objects.filter(user=user, agent=None, raw_text__regex=regex_pattern)
|
||||
query = FileObject.objects.filter(user=user, agent=None, raw_text__iregex=regex_pattern)
|
||||
if path_prefix:
|
||||
query = query.filter(file_name__startswith=path_prefix)
|
||||
return await sync_to_async(list)(query)
|
||||
|
||||
@@ -2900,7 +2900,7 @@ async def grep_files(
|
||||
# Validate regex pattern
|
||||
path_prefix = path_prefix or ""
|
||||
try:
|
||||
regex = re.compile(regex_pattern)
|
||||
regex = re.compile(regex_pattern, re.IGNORECASE)
|
||||
except re.error as e:
|
||||
yield {
|
||||
"query": _generate_query(0, 0, path_prefix, regex_pattern),
|
||||
|
||||
Reference in New Issue
Block a user