Lowercase input of istartswith/iendswith (#1359)

To be symmetric with other case insensitive methods
that lowercase both operands in comparison
This commit is contained in:
Elan Ruusamäe 2024-02-18 00:35:53 +02:00 committed by GitHub
parent 7c99d4af05
commit 4b67b4db5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,9 +22,9 @@ OPERATORS = {
'lt': lambda v, q: v < q,
'lte': lambda v, q: v <= q,
'startswith': lambda v, q: v.startswith(q),
'istartswith': lambda v, q: v.lower().startswith(q),
'istartswith': lambda v, q: v.lower().startswith(q.lower()),
'endswith': lambda v, q: v.endswith(q),
'iendswith': lambda v, q: v.lower().endswith(q),
'iendswith': lambda v, q: v.lower().endswith(q.lower()),
'exists': lambda v, q: v is not None if q else v is None,
'regex': lambda v, q: bool(re.search(q, v)),
'iregex': lambda v, q: bool(re.search(q, v, flags=re.IGNORECASE)),