mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-08 15:55:31 +01:00
Add tests and improve whitespace handling
This commit is contained in:
parent
6a36a4ec97
commit
83746a9aeb
2 changed files with 32 additions and 5 deletions
|
|
@ -128,11 +128,11 @@ class MatchingModel(models.Model):
|
|||
Example:
|
||||
' some random words "with quotes " and spaces'
|
||||
==>
|
||||
['some', 'random', 'words', 'with quotes', 'and', 'spaces']
|
||||
['some', 'random', 'words', 'with\s+quotes', 'and', 'spaces']
|
||||
'''
|
||||
findterms = re.compile(r'"([^"]+)"|(\S+)').findall
|
||||
normspace = re.compile(r'\s{2,}').sub
|
||||
return [normspace(' ', (t[0] or t[1]).strip()) for t in findterms(self.match)]
|
||||
normspace = re.compile(r'\s+').sub
|
||||
return [normspace(r'\s+', (t[0] or t[1]).strip()) for t in findterms(self.match)]
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue