Skip to content
Permalink
Browse files

Fix #3140 — enforce trailing slash for directories in auto

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information...
Kwpolska committed Aug 25, 2018
1 parent c3625df commit d60442344608608d2309f4aca6af75f8e4eb6280
Showing with 9 additions and 2 deletions.
  1. +3 −0 CHANGES.txt
  2. +6 −2 nikola/plugins/command/auto/__init__.py
@@ -20,6 +20,9 @@ Features
Bugfixes
--------

* Enforce trailing slash for directories in ``nikola auto``
(Issue #3140)

New in v8.0.0b3 (changes since Beta 2)
======================================

@@ -38,7 +38,7 @@
import aiohttp
from aiohttp import web
from aiohttp.web_urldispatcher import StaticResource
from aiohttp.web_exceptions import HTTPNotFound, HTTPForbidden
from aiohttp.web_exceptions import HTTPNotFound, HTTPForbidden, HTTPMovedPermanently
from aiohttp.web_response import Response
from aiohttp.web_fileresponse import FileResponse
except ImportError:
@@ -432,7 +432,11 @@ def handle_file(self, request, filename, from_index=None):
if filename.endswith('/') or not filename:
ret = yield from self.handle_file(request, filename + 'index.html', from_index=filename)
else:
ret = yield from self.handle_file(request, filename + '/index.html', from_index=filename)
# Redirect and add trailing slash so relative links work (Issue #3140)
new_url = request.rel_url.path + '/'
if request.rel_url.query_string:
new_url += '?' + request.rel_url.query_string
raise HTTPMovedPermanently(new_url)
elif filepath.is_file():
ct, encoding = mimetypes.guess_type(str(filepath))
encoding = encoding or 'utf-8'

0 comments on commit d604423

Please sign in to comment.
You can’t perform that action at this time.