Skip to content

fix: normalize ContributeFooter route before GitHub link#446

Open
tansawit wants to merge 2 commits intosecurity-alliance:developfrom
tansawit:fix/contribute-footer-path
Open

fix: normalize ContributeFooter route before GitHub link#446
tansawit wants to merge 2 commits intosecurity-alliance:developfrom
tansawit:fix/contribute-footer-path

Conversation

@tansawit
Copy link
Copy Markdown

@tansawit tansawit commented Apr 6, 2026

Summary

Fixes ContributeFooter.tsx URL generation to handle trailing slashes in window.location.pathname.

Problem

Routes like /intro/introduction/ were being transformed into intro/introduction/.mdx, producing invalid GitHub links (for example .../intro/introduction/.mdx).

Change

  • Normalize path from window.location.pathname by trimming leading and trailing /.
  • Avoid generating a path for / home route.
  • Result is correct: /intro/introduction/ -> intro/introduction.mdx.

Validation

  • Manual path normalization check via quick Node verification for common routes.

Frameworks PR Checklist

  • Describe your changes
  • If you are touching an existing piece of content, tag current contributors from the attribution list
  • If there is a steward for that framework, ask the steward to review it
  • If you're modifying the general outline, make sure to update it in vocs.config.ts adding the dev: true parameter
  • If you need feedback for your content from the wider community, share the PR in our Discord
  • Review changes to ensure there are no typos

Files

  • components/footer/ContributeFooter.tsx

@scode2277
Copy link
Copy Markdown
Collaborator

scode2277 commented Apr 7, 2026

Hey @tansawit! Thanks for the effort you put into this.
Could you provide more details on how to reproduce the bug? I tried reproducing it on my end but it seems to work all right, so I'm curious to know if I might be missing something.

Thanks again for the time and sorry you experienced issues in finding the pages on github 🙏🏻

@tansawit
Copy link
Copy Markdown
Author

@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

@scode2277
Copy link
Copy Markdown
Collaborator

scode2277 commented Apr 21, 2026

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.

Copy link
Copy Markdown
Collaborator

@frameworks-volunteer frameworks-volunteer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
frameworks ✅ Ready (View Log) Visit Preview 1dc2e6d

@mattaereal
Copy link
Copy Markdown
Collaborator

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants