forked from UKSOURCE/hailearning.edu.vn
14 lines
359 B
TypeScript
14 lines
359 B
TypeScript
export const imageUrl = (path?: string) => {
|
|
// Không có ảnh → ảnh mặc định
|
|
if (!path) return "/_images/default.jpg";
|
|
|
|
// Đã là full URL
|
|
if (path.startsWith("http")) return path;
|
|
|
|
const base = (
|
|
process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001"
|
|
).replace(/\/$/, "");
|
|
|
|
return `${base}/${path.replace(/^\//, "")}`;
|
|
};
|