13 lines
339 B
TypeScript
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);
|
|
};
|