mirror of
				https://git.sr.ht/~tsileo/microblog.pub
				synced 2025-06-05 21:59:23 +02:00 
			
		
		
		
	Add slugify helper
This commit is contained in:
		
							
								
								
									
										8
									
								
								app/utils/text.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								app/utils/text.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
import re
 | 
			
		||||
import unicodedata
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def slugify(text: str) -> str:
 | 
			
		||||
    value = unicodedata.normalize("NFKC", text)
 | 
			
		||||
    value = re.sub(r"[^\w\s-]", "", value.lower())
 | 
			
		||||
    return re.sub(r"[-\s]+", "-", value).strip("-_")
 | 
			
		||||
		Reference in New Issue
	
	Block a user