Files
ipv6-sims/app/utils/image.ts
T
2026-05-13 19:00:35 +07:00

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(/^\//, "")}`;
};