From 493fc2bcd5554f196b3d49696f08653026c0919b Mon Sep 17 00:00:00 2001 From: Darius Cepulis Date: Fri, 13 Feb 2026 08:09:26 -0600 Subject: [PATCH] fix(site): strip trailing slashes from pathname when copying markdown also: more work on $483 --- site/src/components/CopyMarkdownButton.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/site/src/components/CopyMarkdownButton.tsx b/site/src/components/CopyMarkdownButton.tsx index f948cbab..f4f68d87 100644 --- a/site/src/components/CopyMarkdownButton.tsx +++ b/site/src/components/CopyMarkdownButton.tsx @@ -25,7 +25,9 @@ export default function CopyMarkdownButton({ className, style }: CopyMarkdownBut setState({ status: 'loading' }); // Get current pathname and construct markdown URL - const pathname = window.location.pathname; + // Strip trailing slashes so `/guide/` becomes `/guide.md`, not `/guide/.md` + // Astro should forbid trailing slashes, but infra might add them back on (e.g., Netlify) + const pathname = window.location.pathname.replace(/\/+$/, ''); const mdUrl = `${pathname}.md`; // Create fetch promise - in dev mode, return helpful message @@ -101,7 +103,7 @@ export default function CopyMarkdownButton({ className, style }: CopyMarkdownBut 'inline-flex items-center justify-center' )} > - Copy as Markdown + Copy Markdown