From 95210c8bcb734b3747d374f63d3184657b1dbfab Mon Sep 17 00:00:00 2001 From: Nizzy <140507264+nizzyabi@users.noreply.github.com> Date: Sat, 28 Dec 2024 22:07:24 -0500 Subject: [PATCH] fix: embed showing chat (#18404) * fix: embed showing chat * change url check to starts with * hashmap through pathname --- apps/web/lib/plain/plainChat.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/web/lib/plain/plainChat.tsx b/apps/web/lib/plain/plainChat.tsx index d80699c3638f09..f3bba3fdf5eae9 100644 --- a/apps/web/lib/plain/plainChat.tsx +++ b/apps/web/lib/plain/plainChat.tsx @@ -79,11 +79,16 @@ const PlainChat = () => { const userEmail = session?.user?.email; const isAppDomain = useMemo(() => { - const restrictedPaths = process.env.NEXT_PUBLIC_PLAIN_CHAT_EXCLUDED_PATHS?.split(",") || []; + const restrictedPathsSet = new Set( + (process.env.NEXT_PUBLIC_PLAIN_CHAT_EXCLUDED_PATHS?.split(",") || []).map((path) => path.trim()) + ); + + const pathSegments = pathname?.split("/").filter(Boolean) || []; + return ( typeof window !== "undefined" && window.location.origin === process.env.NEXT_PUBLIC_WEBAPP_URL && - !restrictedPaths.some((path) => pathname?.startsWith(path.trim())) + !pathSegments.some((segment) => restrictedPathsSet.has(segment)) ); }, [pathname]);