perf: Regular command groups can be filled in with new lines

pull/15870/head
feng 2025-08-19 15:48:22 +08:00 committed by ZhaoJiSen
parent e1b96e01eb
commit 36e01a316c
1 changed files with 3 additions and 3 deletions

View File

@ -34,16 +34,16 @@ class CommandGroup(JMSOrgBaseModel):
@lazyproperty
def pattern(self):
content = self.content.replace('\r\n', '\n')
if self.type == 'command':
s = self.construct_command_regex(self.content)
s = self.construct_command_regex(content)
else:
s = r'{0}'.format(self.content)
s = r'{0}'.format(r'{}'.format('|'.join(content.split('\n'))))
return s
@classmethod
def construct_command_regex(cls, content):
regex = []
content = content.replace('\r\n', '\n')
for _cmd in content.split('\n'):
cmd = re.sub(r'\s+', ' ', _cmd)
cmd = re.escape(cmd)