Skip to content

Commit

Permalink
Take care of pretty URL exceptions
Browse files Browse the repository at this point in the history
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
Kwpolska committed Mar 28, 2017
1 parent bee4594 commit 6a0a1bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 2 additions & 4 deletions nikola/plugins/task/page_index.py
Expand Up @@ -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 '']

Expand Down
1 change: 1 addition & 0 deletions tests/test_integration.py
Expand Up @@ -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."""

Expand Down

0 comments on commit 6a0a1bd

Please sign in to comment.