mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-11-04 01:12:08 +01:00 
			
		
		
		
	Preserve dashes in Alias normalisation
This commit is contained in:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user