Fix double slash issues in library page URL generation#1485
Merged
Conversation
- Fix URL construction in library.py to handle empty prefix correctly - Fix get_component_link function to avoid double slashes when prefix is empty - Fix category overview links to handle empty prefix properly - Fix library preview page URL generation This resolves 404 errors on library component links caused by URLs like /docs/library//data-display Co-Authored-By: Alek <alek@pynecone.io>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
There was a problem hiding this comment.
PR Summary
Fixed URL path generation across the component library system to prevent double slashes and ensure consistent routing behavior.
- Modified
pcweb/components/docpage/sidebar/sidebar_items/component_lib.pyto improve prefix path handling inget_component_linkandget_category_children - Updated
pcweb/pages/docs/library.pyto properly constructhrefattributes with conditional trailing slashes - Fixed URL generation in
pcweb/pages/library_previews.pyby adding trailing slashes only when prefixes exist
3 files reviewed, no comments
Edit PR Review Bot Settings | Greptile
masenf
approved these changes
Jul 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix double slash issues in library page URL generation
Summary
Fixed broken links throughout the library documentation page caused by double slashes in URLs (e.g.,
/docs/library//data-displayinstead of/docs/library/data-display). The issue occurred in URL construction logic when theprefixparameter was empty for core components, resulting in 404 errors when users clicked on component links.Changes made:
library.pyto conditionally include prefix only when non-emptyget_component_linkfunction to handle empty prefix correctlyReview & Testing Checklist for Human
/graphing/prefix (e.g., Charts, General, Other Charts sections)/docs/library/{category}/for core components and/docs/library/graphing/{category}/for graphing componentsDiagram
%%{ init : { "theme" : "default" }}%% graph TB LibraryPage["pcweb/pages/docs/library.py<br/>Main library page"]:::major-edit ComponentLib["pcweb/components/docpage/sidebar/<br/>sidebar_items/component_lib.py<br/>URL generation logic"]:::major-edit LibraryPreviews["pcweb/pages/library_previews.py<br/>Component preview pages"]:::major-edit LibraryPage -->|"generates gallery links"| ComponentLib LibraryPreviews -->|"uses get_component_link"| ComponentLib ComponentLib -->|"creates URLs for"| CoreComponents["Core Components<br/>(no prefix)"]:::context ComponentLib -->|"creates URLs for"| GraphingComponents["Graphing Components<br/>(/graphing/ prefix)"]:::context subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
prefixparameter for core components caused string concatenation like/docs/library/${empty_prefix}/${category}resulting in double slashes