Skip to content

Commit 42b92cf

Browse files
committed
Add trailing slash to links
This re-fixes a bug that I fixed in commit 2ba7617 but which I un-fixed at some subsequent point.
1 parent 97d82ba commit 42b92cf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

godoctopus.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,15 @@ def run(self) -> None:
463463
branch_dir.mkdir(parents=True)
464464

465465
item["size"] = self.download_and_extract(url, branch_dir)
466-
item["relative_path"] = branch_dir.relative_to(
467-
branches_dir, walk_up=True
468-
)
466+
relative_path = str(branch_dir.relative_to(branches_dir))
467+
# The trailing slash is significant. GitHub Pages serves a
468+
# redirect to the trailing-slash version, but in the edge case
469+
# where the directory name contains a character that must be
470+
# URL-escaped, the character gets mangled.
471+
# See commit 2ba7617658bd089015aeb39dd9e190a788bd12cf.
472+
if not relative_path.endswith("/"):
473+
relative_path += "/"
474+
item["relative_path"] = relative_path
469475

470476
build_url = self.base_url + str(branch_dir.relative_to(dest_dir))
471477
status.build_url = build_url

0 commit comments

Comments
 (0)