mirror of
https://github.com/simple-login/app.git
synced 2024-11-02 20:01:01 +01:00
19 lines
497 B
Python
19 lines
497 B
Python
import re
|
|
|
|
import re2
|
|
|
|
from app.log import LOG
|
|
|
|
|
|
def regex_match(rule_regex: str, local):
|
|
regex = re2.compile(rule_regex)
|
|
try:
|
|
if re2.fullmatch(regex, local):
|
|
return True
|
|
except TypeError: # re2 bug "Argument 'pattern' has incorrect type (expected bytes, got PythonRePattern)"
|
|
LOG.w("use re instead of re2 for %s %s", rule_regex, local)
|
|
regex = re.compile(rule_regex)
|
|
if re.fullmatch(regex, local):
|
|
return True
|
|
return False
|