From 1188acbf7754b5272cb9c1275cfb3c302fa56166 Mon Sep 17 00:00:00 2001 From: Amy Date: Tue, 17 Mar 2026 14:26:09 -0400 Subject: [PATCH] fix: properly check if link is in scope of app Signed-off-by: Amy --- .../components/markdown/plugins/anchors.tsx | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/client/components/markdown/plugins/anchors.tsx b/packages/client/components/markdown/plugins/anchors.tsx index f567bc341..10af20f37 100644 --- a/packages/client/components/markdown/plugins/anchors.tsx +++ b/packages/client/components/markdown/plugins/anchors.tsx @@ -44,6 +44,19 @@ const internalLink = cva({ }, }); +function inAppScope(link: URL): boolean { + return ( + [ + location.origin, + "https://old.stoat.chat", + "https://revolt.chat", + "https://app.revolt.chat", + "https://stoat.chat", + ].includes(link.origin) && + /\/(app|home|pwa|dev|invite|bot|friends|server)\/?/.test(link.pathname) + ); +} + export function RenderAnchor( props: { disabled?: boolean } & JSX.AnchorHTMLAttributes, ) { @@ -73,16 +86,7 @@ export function RenderAnchor( } // Determine whether it's in our scope - if ( - [ - location.origin, - // legacy - "https://app.revolt.chat", - "https://revolt.chat", - // new - "https://stoat.chat", - ].includes(url.origin) - ) { + if (inAppScope(url)) { const client = useClient(); const params = paramsFromPathname(url.pathname);