Skip to content

Commit

Permalink
Rework conditionals to not be inline
Browse files Browse the repository at this point in the history
  • Loading branch information
seemethere authored Dec 25, 2016
1 parent 2003ece commit 29f3c22
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sanic/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ async def _handler(request, file_uri=None):
# served. os.path.realpath seems to be very slow
if file_uri and '../' in file_uri:
raise InvalidUsage("Invalid URL")

# Merge served directory and requested file if provided
# Strip all / that in the beginning of the URL to help prevent python
# from herping a derp and treating the uri as an absolute path
file_path = path.join(file_or_directory, sub('^[/]*', '', file_uri)) \
if file_uri else file_or_directory
file_path = file_or_directory
if file_uri:
file_path = path.join(
file_or_directory, sub('^[/]*', '', file_uri))

# URL decode the path sent by the browser otherwise we won't be able to
# match filenames which got encoded (filenames with spaces etc)
Expand Down

0 comments on commit 29f3c22

Please sign in to comment.