Skip to content

Commit

Permalink
Fix #2645 (h/t @Benaiah)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Feb 21, 2017
1 parent 948df1e commit f4ea4f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -16,6 +16,7 @@ Features
Bugfixes
--------

* Fix mimetype guessing in auto mode (Issue #2645)
* Fix filters.html5lib_xmllike for laters html5lib (Issue #2648)
* Skip the current post in post lists (Issue #2666)
* Fix poor performance when compiling multiple markdown documents with
Expand Down
6 changes: 5 additions & 1 deletion nikola/plugins/command/auto/__init__.py
Expand Up @@ -298,8 +298,12 @@ def serve_static(self, environ, start_response):
p_uri = urlparse(uri)
f_path = os.path.join(self.site.config['OUTPUT_FOLDER'], *[unquote(x) for x in p_uri.path.split('/')])

# mimetypes.guess_type can't handle query strings, so we need
# to strip the URI to only the path for mimetype guessing
stripped_uri = urlparse.urljoin(url, p_uri.path)

# ‘Pretty’ URIs and root are assumed to be HTML
mimetype = 'text/html' if uri.endswith('/') else mimetypes.guess_type(uri)[0] or 'application/octet-stream'
mimetype = 'text/html' if uri.endswith('/') else mimetypes.guess_type(stripped_uri)[0] or 'application/octet-stream'

if os.path.isdir(f_path):
if not p_uri.path.endswith('/'): # Redirect to avoid breakage
Expand Down

0 comments on commit f4ea4f4

Please sign in to comment.