fix: normalize ContributeFooter route before GitHub link#446
fix: normalize ContributeFooter route before GitHub link#446tansawit wants to merge 2 commits intosecurity-alliance:developfrom
Conversation
|
Hey @tansawit! Thanks for the effort you put into this.
Thanks again for the time and sorry you experienced issues in finding the pages on github 🙏🏻 |
|
@scode2277 sorry for the late reply. I went to https://frameworks.securityalliance.org/intro/introduction, scroll to the bottom, and click on "Contribute Today" seal.mp4 |
|
Thanks for the video and all the informations @tansawit! I understood now why i couldn't reproduce it the first time: i was trying it on different pages and navigating between pages uses React Router client-side, which strips the trailing slash from the URL, so it was not visible to me and all was working as expected. After digging into Vocs internals though, i found out that: on direct load or reload, the server redirects to the directory path (since pages are prerendered as index.html inside directories) and the trailing slash appears. So window.location.pathname is genuinely inconsistent depending on how you arrived at the page. Your fix handles both cases correctly so it's worth adding it! One note though, regarding the merging: we require all commits to be verified otherwise merging is blocked. We made a small guide to fix it here -> https://frameworks.securityalliance.org/contribute/contributing/#fixing-unsigned-commits. Keep in mind that this guide assumes you already have a signing key set up. |
frameworks-volunteer
left a comment
There was a problem hiding this comment.
Model: z-ai/glm-5.1 Reasoning: high Provider: openrouter
Approve. Clean, minimal fix.
Security: No issues. Regex is safe, no injection vectors, rel="noopener noreferrer" already present on the external link.
QA: Regex /^\/+|\/+$/g correctly strips leading/trailing slashes. Home route / now yields empty filePath, so the contribute button links to the docs directory -- acceptable. The fix correctly prevents paths like /intro/introduction/ from producing intro/introduction/.mdx.
One minor note (non-blocking): on the home route, the contribute button still renders and links to the directory listing at docs/pages/. Could consider hiding it when filePath is empty, but that's a UX refinement, not a bug.
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
|
@tansawit just missing your signed commits to be able to merge, there's a section in the contribution that explains this, otherwise any ai will help you through |
Summary
Fixes
ContributeFooter.tsxURL generation to handle trailing slashes inwindow.location.pathname.Problem
Routes like
/intro/introduction/were being transformed intointro/introduction/.mdx, producing invalid GitHub links (for example.../intro/introduction/.mdx).Change
window.location.pathnameby trimming leading and trailing/./home route./intro/introduction/->intro/introduction.mdx.Validation
Frameworks PR Checklist
vocs.config.tsadding thedev: trueparameterFiles
components/footer/ContributeFooter.tsx