diff --git a/components/footer/ContributeFooter.tsx b/components/footer/ContributeFooter.tsx index 17385063..1f0db5d2 100644 --- a/components/footer/ContributeFooter.tsx +++ b/components/footer/ContributeFooter.tsx @@ -13,8 +13,8 @@ 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(/^\/+|\/+$/g, ""); + const filePath = sanitizedPath ? `${sanitizedPath}.mdx` : ""; setCurrentPath(filePath); }, []); @@ -44,4 +44,3 @@ export function ContributeFooter({ ); } -