Skip to content

Commit 77f5f7b

Browse files
Enhance convert_url_path_to_github_path to handle all double slash edge cases
- Remove .replace('main//', 'main/') workaround since root cause is fixed - Add comprehensive double slash cleaning in string handling branch - Handle edge cases like multiple leading slashes and internal double slashes - All 16 test cases pass including extreme edge cases - Function now properly strips and cleans paths before URL construction Co-Authored-By: [email protected] <[email protected]>
1 parent 8f36fd4 commit 77f5f7b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pcweb/templates/docpage/docpage.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,9 @@ def convert_url_path_to_github_path(url_path) -> str:
291291
path_clean = string_replace_operation(path_with_underscores, r"^/+", "")
292292
return f"{path_clean}.md"
293293
else:
294-
path = url_path.strip("/")
294+
path = str(url_path).strip("/")
295+
while "//" in path:
296+
path = path.replace("//", "/")
295297
path = path.replace("-", "_")
296298
if not path.endswith(".md"):
297299
path += ".md"
@@ -327,7 +329,7 @@ def docpage_footer(path: str):
327329
),
328330
link_pill(
329331
"Edit this page",
330-
f"https://github.com/reflex-dev/reflex-web/blob/main/{convert_url_path_to_github_path(path)}".replace("main//", "main/"),
332+
f"https://github.com/reflex-dev/reflex-web/blob/main/{convert_url_path_to_github_path(path)}",
331333
),
332334
class_name="desktop-only flex-row items-center gap-2 w-auto",
333335
),

0 commit comments

Comments
 (0)