Permalink
Browse files

Take care of pretty URL exceptions

Also simplifies the removal code with str.rstrip() — it’s always
index.html.

h/t @felixfontein

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information...
1 parent bee4594 commit 6a0a1bdc24abdac2569089fce8b4016d20cefae2 @Kwpolska Kwpolska committed Mar 28, 2017
Showing with 3 additions and 4 deletions.
  1. +2 −4 nikola/plugins/task/page_index.py
  2. +1 −0 tests/test_integration.py
@@ -64,10 +64,8 @@ def is_enabled(self, lang=None):
def classify(self, post, lang):
"""Classify the given post for the given language."""
destpath = post.destination_path(lang, sep='/')
- if self.site.config["PRETTY_URLS"]:
- index_len = len(self.site.config["INDEX_FILE"])
- if destpath[-(1 + index_len):] == '/' + self.site.config["INDEX_FILE"]:
- destpath = destpath[:-(1 + index_len)]
+ if post._has_pretty_url(lang):
+ destpath = destpath.rstrip('/index.html')
i = destpath.rfind('/')
return [destpath[:i] if i >= 0 else '']
@@ -544,6 +544,7 @@ def fill_site(self):
with io.open(target_path, "w+", encoding="utf8") as outf:
outf.write("foo")
+
class PageIndexTest(EmptyBuildTest):
"""Test if PAGE_INDEX works, with PRETTY_URLS disabled."""

0 comments on commit 6a0a1bd

Please sign in to comment.