Closes #15465: Clean up settings.py

This commit is contained in:
Jeremy Stretch
2024-03-22 14:59:04 -04:00
parent 45c99e4477
commit 6973228825
2 changed files with 98 additions and 107 deletions

View File

@@ -1,5 +1,6 @@
__all__ = (
'title',
'trailing_slash',
)
@@ -8,3 +9,10 @@ def title(value):
Improved implementation of str.title(); retains all existing uppercase letters.
"""
return ' '.join([w[0].upper() + w[1:] for w in str(value).split()])
def trailing_slash(value):
"""
Remove a leading slash (if any) and include a trailing slash, except for empty strings.
"""
return f'{value.strip("/")}/' if value else ''