Skip to content

Commit 399e302

Browse files
committedJan 24, 2019
Add only one slash before ? in serve
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent 0552489 commit 399e302

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
 

‎CHANGES.txt

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Bugfixes
88
"ignored_assets" key in theme meta files (Issue #3210)
99
* Fix error when ``nikola new_post`` receives directory name as
1010
path (Issue #3207)
11+
* Add slashes to paths with query strings in ``nikola serve``
12+
only if there isn’t one before ``?``
1113
* Read listings files as UTF-8
1214
* Set one-file status basing on default language only (Issue #3191)
1315
* Don’t warn if post status is set to ``published`` explicitly

‎nikola/plugins/command/serve.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ def send_head(self):
215215
path = self.translate_path(self.path)
216216
f = None
217217
if os.path.isdir(path):
218-
if not self.path.endswith('/'):
218+
path_parts = list(self.path.partition('?'))
219+
if not path_parts[0].endswith('/'):
219220
# redirect browser - doing basically what apache does
220-
self.send_response(301)
221-
path_parts = list(self.path.partition('?'))
222221
path_parts[0] += '/'
222+
self.send_response(301)
223223
self.send_header("Location", ''.join(path_parts))
224224
# begin no-cache patch
225225
# For redirects. With redirects, caching is even worse and can

0 commit comments

Comments
 (0)
Please sign in to comment.