Skip to content

Commit

Permalink
Merge 6a1e0d6 into d063bc9
Browse files Browse the repository at this point in the history
  • Loading branch information
iambibhas committed Aug 6, 2020
2 parents d063bc9 + 6a1e0d6 commit 3c03975
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions baseframe/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,16 @@ def timestamp_filter(value):
else:
ts = value
return ts


@baseframe.app_template_filter('cleanurl')
def cleanurl_filter(url):
if url.startswith('http://'):
url = url[7:]
elif url.startswith('https://'):
url = url[8:]
if url.endswith('/') and url.count('/') == 1:
# Remove trailing slash if applied to end of domain name
# but leave it in if it's a path
url = url[:-1]
return url

0 comments on commit 3c03975

Please sign in to comment.