From 9a0b83c99243395eeda7024d4a8b8c869fa7b2a0 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Sun, 6 Mar 2022 17:27:13 -0800 Subject: [PATCH] Fix basePath? --- client/components/Link.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/components/Link.tsx b/client/components/Link.tsx index 836df881..6bb16a77 100644 --- a/client/components/Link.tsx +++ b/client/components/Link.tsx @@ -3,8 +3,9 @@ import { useRouter } from "next/router"; const Link = (props: LinkProps) => { const { basePath } = useRouter(); - const href = basePath ? `/${basePath}/${props.href}` : props.href; + const propHrefWithoutLeadingSlash = props.href ? props.href.replace(/^\//, "") : props.href; + const href = basePath ? `/${basePath}/${propHrefWithoutLeadingSlash}` : props.href; return } -export default Link \ No newline at end of file +export default Link