25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
function publicWebBase(): string {
|
|
const fromEnv =
|
|
(typeof import.meta.env.VITE_PUBLIC_WEB_BASE === "string" && import.meta.env.VITE_PUBLIC_WEB_BASE.trim()) ||
|
|
(typeof import.meta.env.VITE_EVENTBUZZ_PUBLIC_URL === "string" && import.meta.env.VITE_EVENTBUZZ_PUBLIC_URL.trim());
|
|
if (fromEnv) return fromEnv.replace(/\/+$/, "");
|
|
|
|
// Dashboard (5173) is not the public web app; avoid using its origin for microsite links.
|
|
if (import.meta.env.DEV) return "http://localhost:5175";
|
|
|
|
return (typeof window !== "undefined" ? window.location.origin : "").replace(/\/+$/, "");
|
|
}
|
|
|
|
export function micrositePublicPageUrl(folder: string): string | null {
|
|
const base = (import.meta.env.VITE_MICROSITE_PUBLIC_BASE as string | undefined)?.replace(/\/+$/, "");
|
|
if (!base || !folder.trim()) return null;
|
|
const slug = folder.replace(/^\/+|\/+$/g, "");
|
|
return `${base}/${slug}/index.html`;
|
|
}
|
|
|
|
export function defaultMicrositePageUrl(eventId: string): string | null {
|
|
const base = publicWebBase();
|
|
if (!base || !eventId.trim()) return null;
|
|
return `${base}/event/${eventId}`;
|
|
}
|