Skip to content

Commit b8978e0

Browse files
committed
fix: Judge regular matching using fullmatch
1 parent 77a7dd6 commit b8978e0

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

apps/application/flow/compare/regex_compare.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@
1111
from .compare import Compare
1212
from common.cache.mem_cache import MemCache
1313

14-
1514
match_cache = MemCache('regex', {
16-
'TIMEOUT': 3600, # 缓存有效期为 1 小时
15+
'TIMEOUT': 3600, # 缓存有效期为 1 小时
1716
'OPTIONS': {
18-
'MAX_ENTRIES': 500, # 最多缓存 500 个条目
19-
'CULL_FREQUENCY': 10, # 达到上限时,删除约 1/10 的缓存
17+
'MAX_ENTRIES': 500, # 最多缓存 500 个条目
18+
'CULL_FREQUENCY': 10, # 达到上限时,删除约 1/10 的缓存
2019
},
2120
})
2221

2322

2423
def compile_and_cache(regex):
2524
match = match_cache.get(regex)
2625
if not match:
27-
match = re.compile(regex).match
26+
match = re.compile(regex).fullmatch
2827
match_cache.set(regex, match)
2928
return match
3029

30+
3131
class RegexCompare(Compare):
3232

3333
def compare(self, source_value, compare, target_value):

0 commit comments

Comments
 (0)