Files
t3code/apps/web/src/branding.logic.ts
T
2026-08-07 18:06:10 -07:00

39 lines
1.2 KiB
TypeScript

const NIGHTLY_SERVER_VERSION_PATTERN = /-nightly\.\d{8}\.\d+$/;
export function formatAppDisplayName(input: {
readonly baseName: string;
readonly stageLabel: string;
}): string {
if (input.stageLabel.trim().toLowerCase() === "latest") {
return input.baseName;
}
return `${input.baseName} (${input.stageLabel})`;
}
export function resolveServerBackedAppStageLabel(input: {
readonly primaryServerVersion: string | null | undefined;
readonly fallbackStageLabel: string;
}): string {
return input.primaryServerVersion &&
NIGHTLY_SERVER_VERSION_PATTERN.test(input.primaryServerVersion)
? "Nightly"
: input.fallbackStageLabel;
}
export function resolveServerBackedAppDisplayName(input: {
readonly baseName: string;
readonly fallbackDisplayName: string;
readonly fallbackStageLabel: string;
readonly primaryServerVersion: string | null | undefined;
}): string {
const stageLabel = resolveServerBackedAppStageLabel({
primaryServerVersion: input.primaryServerVersion,
fallbackStageLabel: input.fallbackStageLabel,
});
return stageLabel === input.fallbackStageLabel
? input.fallbackDisplayName
: formatAppDisplayName({ baseName: input.baseName, stageLabel });
}