Skip to content

Commit 8f36fd4

Browse files
Improve StringVar handling to prevent leading slashes
- Add additional string_replace_operation to strip any remaining leading slashes - Ensures StringVar branch returns clean path without leading slash - Prevents double slash in GitHub URLs when combined with main/{path} - Addresses issue where regex ^/+|/+$ might not fully strip leading slashes in StringVar context Co-Authored-By: [email protected] <[email protected]>
1 parent 026fd7b commit 8f36fd4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pcweb/templates/docpage/docpage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ def convert_url_path_to_github_path(url_path) -> str:
288288

289289
path_no_slashes = string_replace_operation(url_path, r"^/+|/+$", "")
290290
path_with_underscores = string_replace_operation(path_no_slashes, "-", "_")
291-
return f"{path_with_underscores}.md"
291+
path_clean = string_replace_operation(path_with_underscores, r"^/+", "")
292+
return f"{path_clean}.md"
292293
else:
293294
path = url_path.strip("/")
294295
path = path.replace("-", "_")

0 commit comments

Comments
 (0)