Files
ctms/frontend/src/api/baseUrl.ts
T
2026-03-30 22:05:02 +08:00

13 lines
339 B
TypeScript

const trimTrailingSlashes = (value: string): string => value.replace(/\/+$/, "");
export const resolveApiBaseUrl = (rawValue: string | undefined): string => {
const normalized = rawValue?.trim() ?? "";
if (!normalized) {
return "/";
}
if (normalized === "/") {
return "/";
}
return trimTrailingSlashes(normalized);
};