From a8ae13b88ebbf5cf570dc665e7a24c64bc45728a Mon Sep 17 00:00:00 2001 From: tansawit <12265853+tansawit@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:10:58 +0700 Subject: [PATCH 1/2] fix: normalize footer contribute path for trailing slash routes --- components/footer/ContributeFooter.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/footer/ContributeFooter.tsx b/components/footer/ContributeFooter.tsx index 17385063..e62c2ba8 100644 --- a/components/footer/ContributeFooter.tsx +++ b/components/footer/ContributeFooter.tsx @@ -13,8 +13,10 @@ export function ContributeFooter({ const [currentPath, setCurrentPath] = useState(""); useEffect(() => { - const pathname = window.location.pathname; - const filePath = `${pathname.slice(1)}.mdx`; + const sanitizedPath = window.location.pathname + .replace(/\/+$/, "") + .replace(/^\/+/, ""); + const filePath = sanitizedPath ? `${sanitizedPath}.mdx` : ""; setCurrentPath(filePath); }, []); @@ -44,4 +46,3 @@ export function ContributeFooter({ ); } - From 1dc2e6d30dd216bff4aa119610c98e875403f634 Mon Sep 17 00:00:00 2001 From: tansawit <12265853+tansawit@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:13:55 +0700 Subject: [PATCH 2/2] refactor: simplify contribute path normalization --- components/footer/ContributeFooter.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/footer/ContributeFooter.tsx b/components/footer/ContributeFooter.tsx index e62c2ba8..1f0db5d2 100644 --- a/components/footer/ContributeFooter.tsx +++ b/components/footer/ContributeFooter.tsx @@ -13,9 +13,7 @@ export function ContributeFooter({ const [currentPath, setCurrentPath] = useState(""); useEffect(() => { - const sanitizedPath = window.location.pathname - .replace(/\/+$/, "") - .replace(/^\/+/, ""); + const sanitizedPath = window.location.pathname.replace(/^\/+|\/+$/g, ""); const filePath = sanitizedPath ? `${sanitizedPath}.mdx` : ""; setCurrentPath(filePath);