Skip to content

Commit f4ea4f4

Browse files
committedFeb 21, 2017
Fix #2645 (h/t @Benaiah)
1 parent 948df1e commit f4ea4f4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
 

‎CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Features
1616
Bugfixes
1717
--------
1818

19+
* Fix mimetype guessing in auto mode (Issue #2645)
1920
* Fix filters.html5lib_xmllike for laters html5lib (Issue #2648)
2021
* Skip the current post in post lists (Issue #2666)
2122
* Fix poor performance when compiling multiple markdown documents with

‎nikola/plugins/command/auto/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,12 @@ def serve_static(self, environ, start_response):
298298
p_uri = urlparse(uri)
299299
f_path = os.path.join(self.site.config['OUTPUT_FOLDER'], *[unquote(x) for x in p_uri.path.split('/')])
300300

301+
# mimetypes.guess_type can't handle query strings, so we need
302+
# to strip the URI to only the path for mimetype guessing
303+
stripped_uri = urlparse.urljoin(url, p_uri.path)
304+
301305
# ‘Pretty’ URIs and root are assumed to be HTML
302-
mimetype = 'text/html' if uri.endswith('/') else mimetypes.guess_type(uri)[0] or 'application/octet-stream'
306+
mimetype = 'text/html' if uri.endswith('/') else mimetypes.guess_type(stripped_uri)[0] or 'application/octet-stream'
303307

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

0 commit comments

Comments
 (0)
Please sign in to comment.