From ca7f4791eddecae7d165e79e38d0d69a94ceeec0 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 30 Aug 2020 17:28:36 +0200 Subject: [PATCH] Preserve dashes in Alias normalisation --- apps/note/models/notes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/note/models/notes.py b/apps/note/models/notes.py index a7fdcf61..4980fb72 100644 --- a/apps/note/models/notes.py +++ b/apps/note/models/notes.py @@ -247,10 +247,10 @@ class Alias(models.Model): Normalizes a string: removes most diacritics, does casefolding and ignore non-ASCII characters """ return ''.join( - char for char in unicodedata.normalize('NFKD', string.casefold().replace('æ', 'ae') - .replace('œ', 'oe').replace('-', '_')) + char for char in unicodedata.normalize('NFKD', string.casefold().replace('æ', 'ae').replace('œ', 'oe')) if all(not unicodedata.category(char).startswith(cat) - for cat in {'M', 'P', 'Z', 'C'})).casefold().encode('ascii', 'ignore').decode('ascii') + for cat in {'M', 'Pc', 'Pe', 'Pf', 'Pi', 'Po', 'Ps', 'Z', 'C'}))\ + .casefold().encode('ascii', 'ignore').decode('ascii') def clean(self): normalized_name = self.normalize(self.name)