diff --git a/apps/web/pages/_document.tsx b/apps/web/pages/_document.tsx index 006b73c8fa..f0a6670b43 100644 --- a/apps/web/pages/_document.tsx +++ b/apps/web/pages/_document.tsx @@ -29,7 +29,11 @@ class MyDocument extends Document { const asPath = ctx.asPath || ""; // Use a dummy URL as default so that URL parsing works for relative URLs as well. We care about searchParams and pathname only const parsedUrl = new URL(asPath, "https://dummyurl"); - const isEmbed = parsedUrl.pathname.endsWith("/embed") || parsedUrl.searchParams.get("embedType") !== null; + const isEmbedSnippetGeneratorPath = parsedUrl.pathname.startsWith("/event-types"); + // FIXME: Revisit this logic to remove embedType query param check completely. Ideally, /embed should always be there at the end of the URL. Test properly and then remove it. + const isEmbed = + (parsedUrl.pathname.endsWith("/embed") || parsedUrl.searchParams.get("embedType") !== null) && + !isEmbedSnippetGeneratorPath; const embedColorScheme = parsedUrl.searchParams.get("ui.color-scheme"); const initialProps = await Document.getInitialProps(ctx); return { isEmbed, embedColorScheme, nonce, ...initialProps }; diff --git a/packages/features/embed/Embed.tsx b/packages/features/embed/Embed.tsx index be757d4255..afebad31f0 100644 --- a/packages/features/embed/Embed.tsx +++ b/packages/features/embed/Embed.tsx @@ -82,12 +82,6 @@ function useRouterHelpers() { return { goto, removeQueryParams }; } -const getQueryParam = (queryParam: string) => { - const params = new URLSearchParams(window.location.search); - - return params.get(queryParam); -}; - const ThemeSelectControl = ({ children, ...props }: ControlProps<{ value: Theme; label: string }, false>) => { return ( @@ -526,7 +520,7 @@ const EmbedTypeCodeAndPreviewDialogContent = ({ (state) => [state.month, state.selectedDatesAndTimes], shallow ); - const eventId = getQueryParam("eventId"); + const eventId = searchParams.get("eventId"); const calLink = decodeURIComponent(embedUrl); const { data: eventTypeData } = trpc.viewer.eventTypes.get.useQuery( { id: parseInt(eventId as string) },