mirror of
https://github.com/sstent/foodplanner.git
synced 2026-02-01 22:51:37 +00:00
fix remove food, efit food. assed playwright tests
This commit is contained in:
12
app/utils.py
Normal file
12
app/utils.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import re
|
||||
|
||||
def slugify(s):
|
||||
"""
|
||||
Slugifies a string, converting spaces and non-alphanumeric characters to hyphens.
|
||||
"""
|
||||
s = s.lower()
|
||||
s = re.sub(r'[^a-z0-9\s-]', '', s) # Remove all non-alphanumeric characters except spaces and hyphens
|
||||
s = re.sub(r'[-\s]+', '-', s) # Replace spaces and hyphens with a single hyphen
|
||||
s = s.strip('-') # Remove leading/trailing hyphens
|
||||
|
||||
return s
|
||||
Reference in New Issue
Block a user