Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions apps/web/server/lib/[user]/getServerSideProps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { EmbedProps } from "app/WithEmbedSSR";
import type { GetServerSideProps } from "next";
import { encode } from "node:querystring";
import type { z } from "zod";

import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
Expand Down Expand Up @@ -109,7 +108,17 @@ export const getServerSideProps: GetServerSideProps<UserPageProps> = async (cont

// EXAMPLE - context.params: { orgSlug: 'acme', user: 'member0+owner1' }
// EXAMPLE - context.query: { redirect: 'undefined', orgRedirection: 'undefined', user: 'member0+owner1' }
const originalQueryString = new URLSearchParams(context.query as Record<string, string>).toString();
const params = new URLSearchParams();

Object.entries(context.query).forEach(([key, value]) => {
if (Array.isArray(value)) {
value.forEach((v) => params.append(key, v));
} else if (value !== undefined) {
params.append(key, value);
}
});

const originalQueryString = params.toString();
const destinationWithQuery = `${destinationUrl}?${originalQueryString}`;
log.debug(`Dynamic group detected, redirecting to ${destinationUrl}`);
return {
Expand Down Expand Up @@ -161,8 +170,18 @@ export const getServerSideProps: GetServerSideProps<UserPageProps> = async (cont
if (eventTypes.length === 1 && context.query.redirect !== "false") {
// Redirect but don't change the URL
const urlDestination = `/${user.profile.username}/${eventTypes[0].slug}`;
const params = new URLSearchParams();
const { query } = context;
const urlQuery = new URLSearchParams(encode(query));

Object.entries(query).forEach(([key, value]) => {
if (Array.isArray(value)) {
value.forEach((v) => params.append(key, v));
} else if (value !== undefined) {
params.append(key, value as string);
}
});

const urlQuery = params.toString();

return {
redirect: {
Expand Down
Loading