+2








cc99e1697b
* Creating team and preview URL fixes * Renamed function in tests too * fix: Signup from org wizard invitation and other tweaks [CAL-1973] [CAL-1993] [CAL-1994] (#9693) * Fixing signup from org invitation and other tweaks * feat: Organizations no middleware rewrite (#9548) Co-authored-by: Leo Giovanetti <[email protected]> Co-authored-by: zomars <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> * Revert "fix: redirect to 404 page for invalid email verification token" (#9703) * New Crowdin translations by Github Action * refactor: Skip license checks for development (#9375) * Allow closing the embed on clicking the black transparent area (#9706) * New Crowdin translations by Github Action * perf: [CAL-1928] Deduplicate eventTypes.getByViewer query (#9700) Co-authored-by: alannnc <[email protected]> Co-authored-by: Udit Takkar <[email protected]> * perf: Remove useless data on EvenTypes getByViewer endpoint (#9704) * feat: [CAL-910] Pre-select country for phone number (CALCOM-5759) (#9526) Co-authored-by: gitstart-calcom <[email protected]> * Fix settings layout + org headings (#9712) * Simplifying prop * Removing restriction to choose username * Formatting --------- Co-authored-by: Efraín Rochín <[email protected]> Co-authored-by: zomars <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Crowdin Bot <[email protected]> Co-authored-by: alannnc <[email protected]> Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Afzal Sayed <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: GitStart-Cal.com <[email protected]> Co-authored-by: gitstart-calcom <[email protected]> Co-authored-by: sean-brydon <[email protected]> * Fix conditional before hook * Fix lints --------- Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Efraín Rochín <[email protected]> Co-authored-by: zomars <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Crowdin Bot <[email protected]> Co-authored-by: alannnc <[email protected]> Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Afzal Sayed <[email protected]> Co-authored-by: GitStart-Cal.com <[email protected]> Co-authored-by: gitstart-calcom <[email protected]> Co-authored-by: sean-brydon <[email protected]>
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { ALLOWED_HOSTNAMES, RESERVED_SUBDOMAINS, WEBAPP_URL } from "@calcom/lib/constants";
|
|
|
|
/**
|
|
* return the org slug
|
|
* @param hostname
|
|
*/
|
|
export function getOrgSlug(hostname: string) {
|
|
// Find which hostname is being currently used
|
|
const currentHostname = ALLOWED_HOSTNAMES.find((ahn) => {
|
|
const url = new URL(WEBAPP_URL);
|
|
const testHostname = `${url.hostname}${url.port ? `:${url.port}` : ""}`;
|
|
return testHostname.endsWith(`.${ahn}`);
|
|
});
|
|
if (currentHostname) {
|
|
// Define which is the current domain/subdomain
|
|
const slug = hostname.replace(`.${currentHostname}` ?? "", "");
|
|
return slug.indexOf(".") === -1 ? slug : null;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export function orgDomainConfig(hostname: string) {
|
|
const currentOrgDomain = getOrgSlug(hostname);
|
|
return {
|
|
currentOrgDomain,
|
|
isValidOrgDomain: currentOrgDomain !== null && !RESERVED_SUBDOMAINS.includes(currentOrgDomain),
|
|
};
|
|
}
|
|
|
|
export function subdomainSuffix() {
|
|
const urlSplit = WEBAPP_URL.replace("https://", "")?.replace("http://", "").split(".");
|
|
return urlSplit.length === 3 ? urlSplit.slice(1).join(".") : urlSplit.join(".");
|
|
}
|
|
|
|
export function getOrgFullDomain(slug: string, options: { protocol: boolean } = { protocol: true }) {
|
|
return `${options.protocol ? `${new URL(WEBAPP_URL).protocol}//` : ""}${slug}.${subdomainSuffix()}/`;
|
|
}
|