forked from UKSOURCE/ipv6
14 lines
346 B
TypeScript
14 lines
346 B
TypeScript
export const imageUrl = (path?: string) => {
|
|
// No image → default image
|
|
if (!path) return "/_images/default.jpg";
|
|
|
|
// Already a full URL
|
|
if (path.startsWith("http")) return path;
|
|
|
|
const base = (
|
|
process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001"
|
|
).replace(/\/$/, "");
|
|
|
|
return `${base}/${path.replace(/^\//, "")}`;
|
|
};
|