koperasi/services/frontend/app/utils/prefix-file-path.ts
2025-08-08 14:12:40 +07:00

14 lines
338 B
TypeScript

import getEnv from "~/lib/get-env";
export function formatImagePath(imagePath: string): string {
const env = getEnv();
const isExternalImage = imagePath.startsWith("http") || imagePath.startsWith("https");
const baseUrl = env.API_BASE_URL;
if (isExternalImage) {
return imagePath;
}
return `${baseUrl}/${imagePath}`;
}