From b2ac6041ec8f463b6350c3d1d8913ef981ccd629 Mon Sep 17 00:00:00 2001 From: Sowmya Kota Date: Thu, 9 Nov 2023 11:28:14 -0800 Subject: [PATCH] fix: links --- src/components/InternalLink/index.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/InternalLink/index.tsx b/src/components/InternalLink/index.tsx index 7d51a4b11e8..ddf087cffdb 100644 --- a/src/components/InternalLink/index.tsx +++ b/src/components/InternalLink/index.tsx @@ -28,9 +28,17 @@ export default function InternalLink({ href, children }) { const filterKey = filterKeys[filterKind]; if (href.includes('#')) { const hrefParts = href.split('#'); - href = `${hrefParts[0]}q/${filterKind}/${filterKey}#${hrefParts[1]}`; + if (hrefParts[0].endsWith('/')) { + href = `${hrefParts[0]}q/${filterKind}/${filterKey}#${hrefParts[1]}`; + } else { + href = `${hrefParts[0]}/q/${filterKind}/${filterKey}#${hrefParts[1]}`; + } } else { - href += `/q/${filterKind}/${filterKey}`; + if (href.endsWith('/')) { + href += `q/${filterKind}/${filterKey}`; + } else { + href += `/q/${filterKind}/${filterKey}`; + } } } }