Skip to content

Commit

Permalink
Added code to strip trailing slashes on request paths so we are a lit…
Browse files Browse the repository at this point in the history
…tle more user-friendly
  • Loading branch information
wbond committed Feb 9, 2014
1 parent b0ee1d6 commit 829e634
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/lib/trailing_slash_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from bottle import request, redirect, hook


@hook('before_request')
def remove_trailing_slash():
path = request.environ['PATH_INFO']
if len(path) > 1 and path[-1] == '/':
redirect(path.rstrip('/'), 301)

1 change: 1 addition & 0 deletions dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import app.controllers
from app.lib.json_api_middleware import JsonApiMiddleware
from app.lib.trailing_slash_filter import remove_trailing_slash


# For development, serve static files also
Expand Down

0 comments on commit 829e634

Please sign in to comment.