Skip to content

Commit 1a8f908

Browse files
authored
Merge pull request #80 from endlessm/push-vxwwttkwuvyr
Add trailing slash to links
2 parents c90c366 + 42b92cf commit 1a8f908

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

godoctopus.py

Lines changed: 10 additions & 4 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
@@ -521,7 +527,7 @@ def get_pages_config(session: requests.Session, repo: str) -> PagesConfig:
521527

522528
raise ConfigurationError(
523529
"GitHub Pages must be enabled, with the source set to GitHub Actions, in the repository settings.",
524-
f"Go to https://github.com/{ repo }/settings/pages to fix this.",
530+
f"Go to https://github.com/{repo}/settings/pages to fix this.",
525531
)
526532

527533

0 commit comments

Comments
 (0)