Skip to content

Commit

Permalink
fix: embed showing chat (#18404)
Browse files Browse the repository at this point in the history
* fix: embed showing chat

* change url check to starts with

* hashmap through pathname
  • Loading branch information
nizzyabi authored and joeauyeung committed Dec 30, 2024
1 parent 03b1cef commit 95210c8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/web/lib/plain/plainChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit 95210c8

Please sign in to comment.