Skip to content

Commit e5f028f

Browse files
Explain the escaping order in the search pattern helper
1 parent 68e6214 commit e5f028f

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎backend/app/routes/todos.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
def _like_pattern(term: str) -> str:
1717
"""Build a case-insensitive "contains" pattern, escaping LIKE wildcards in the term."""
18+
# Escape the backslash first so the escapes added for % and _ are not doubled.
1819
escaped = term.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_")
1920
return f"%{escaped}%"
2021

0 commit comments

Comments
 (0)