Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Team URL and booker URLs (#13050)

Hariom Balhara4aa0b4cc6599
diff --git a/apps/web/lib/orgMigration.test.ts b/apps/web/lib/orgMigration.test.ts
index 2bf8fb7093f..18b924dbc2e 100644
--- a/apps/web/lib/orgMigration.test.ts
+++ b/apps/web/lib/orgMigration.test.ts
@@ -3,12 +3,14 @@ import prismock from "../../../tests/libs/__mocks__/prisma";
import { describe, expect, it } from "vitest";
import type { z } from "zod";
+import { WEBSITE_URL } from "@calcom/lib/constants";
import type { MembershipRole, Prisma } from "@calcom/prisma/client";
import { RedirectType } from "@calcom/prisma/enums";
import type { teamMetadataSchema } from "@calcom/prisma/zod-utils";
import { moveTeamToOrg, moveUserToOrg, removeTeamFromOrg, removeUserFromOrg } from "./orgMigration";
+const WEBSITE_PROTOCOL = new URL(WEBSITE_URL).protocol;
describe("orgMigration", () => {
describe("moveUserToOrg", () => {
describe("when user email does not match orgAutoAcceptEmail", () => {
@@ -1366,7 +1368,7 @@ async function expectRedirectToBeEnabled({
}
expect(redirect).not.toBeNull();
- expect(redirect?.toUrl).toBe(`http://${orgSlug}.cal.local:3000/${to}`);
+ expect(redirect?.toUrl).toBe(`${WEBSITE_PROTOCOL}//${orgSlug}.cal.local:3000/${to}`);
if (!redirect) {
throw new Error(`Redirect doesn't exist for ${JSON.stringify(tempOrgRedirectWhere)}`);
}
diff --git a/apps/web/test/utils/bookingScenario/test.ts b/apps/web/test/utils/bookingScenario/test.ts
index 74eb503f86c..7a00f894fd8 100644
--- a/apps/web/test/utils/bookingScenario/test.ts
+++ b/apps/web/test/utils/bookingScenario/test.ts
@@ -1,9 +1,11 @@
import type { TestFunction } from "vitest";
+import { WEBSITE_URL } from "@calcom/lib/constants";
import { test } from "@calcom/web/test/fixtures/fixtures";
import type { Fixtures } from "@calcom/web/test/fixtures/fixtures";
import { createOrganization } from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+const WEBSITE_PROTOCOL = new URL(WEBSITE_URL).protocol;
const _testWithAndWithoutOrg = (
description: Parameters<typeof testWithAndWithoutOrg>[0],
fn: Parameters<typeof testWithAndWithoutOrg>[1],
@@ -28,7 +30,7 @@ const _testWithAndWithoutOrg = (
skip,
org: {
organization: org,
- urlOrigin: `http://${org.slug}.cal.local:3000`,
+ urlOrigin: `${WEBSITE_PROTOCOL}//${org.slug}.cal.local:3000`,
},
});
},
diff --git a/packages/features/ee/organizations/lib/orgDomains.ts b/packages/features/ee/organizations/lib/orgDomains.ts
index 461f5e2c03f..ebb0c9d73e3 100644
--- a/packages/features/ee/organizations/lib/orgDomains.ts
+++ b/packages/features/ee/organizations/lib/orgDomains.ts
@@ -1,7 +1,7 @@
import type { Prisma } from "@prisma/client";
import type { IncomingMessage } from "http";
-import { IS_PRODUCTION } from "@calcom/lib/constants";
+import { IS_PRODUCTION, WEBSITE_URL } from "@calcom/lib/constants";
import { ALLOWED_HOSTNAMES, RESERVED_SUBDOMAINS, WEBAPP_URL } from "@calcom/lib/constants";
import logger from "@calcom/lib/logger";
import slugify from "@calcom/lib/slugify";
@@ -100,9 +100,10 @@ export function subdomainSuffix() {
}
export function getOrgFullOrigin(slug: string, options: { protocol: boolean } = { protocol: true }) {
- if (!slug) return options.protocol ? WEBAPP_URL : WEBAPP_URL.replace("https://", "").replace("http://", "");
+ if (!slug)
+ return options.protocol ? WEBSITE_URL : WEBSITE_URL.replace("https://", "").replace("http://", "");
const orgFullOrigin = `${
- options.protocol ? `${new URL(WEBAPP_URL).protocol}//` : ""
+ options.protocol ? `${new URL(WEBSITE_URL).protocol}//` : ""
}${slug}.${subdomainSuffix()}`;
return orgFullOrigin;
}
diff --git a/packages/features/ee/teams/components/TeamListItem.tsx b/packages/features/ee/teams/components/TeamListItem.tsx
index 4355ad64612..0eb04d41405 100644
--- a/packages/features/ee/teams/components/TeamListItem.tsx
+++ b/packages/features/ee/teams/components/TeamListItem.tsx
@@ -107,9 +107,7 @@ export default function TeamListItem(props: Props) {
<span className="text-default text-sm font-bold">{team.name}</span>
<span className="text-muted block text-xs">
{team.slug ? (
- `${getTeamUrlSync({ orgSlug: team.parent ? team.parent.slug : null, teamSlug: team.slug })}/${
- team.slug
- }`
+ `${getTeamUrlSync({ orgSlug: team.parent ? team.parent.slug : null, teamSlug: team.slug })}`
) : (
<Badge>{t("upgrade")}</Badge>
)}
@@ -245,11 +243,10 @@ export default function TeamListItem(props: Props) {
color="secondary"
onClick={() => {
navigator.clipboard.writeText(
- `${
- orgBranding
- ? `${orgBranding.fullDomain}`
- : `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team`
- }/${team.slug}`
+ `${getTeamUrlSync({
+ orgSlug: team.parent ? team.parent.slug : null,
+ teamSlug: team.slug,
+ })}`
);
showToast(t("link_copied"), "success");
}}
@@ -285,11 +282,10 @@ export default function TeamListItem(props: Props) {
<DropdownItem
type="button"
target="_blank"
- href={`${
- orgBranding
- ? `${orgBranding.fullDomain}`
- : `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team`
- }/${team.slug}`}
+ href={`${getTeamUrlSync({
+ orgSlug: team.parent ? team.parent.slug : null,
+ teamSlug: team.slug,
+ })}`}
StartIcon={ExternalLink}>
{t("preview_team") as string}
</DropdownItem>