export function toDisplayImageUrl(imageUrl?: string | null) {
  if (!imageUrl) {
    return undefined
  }

  try {
    const parsedUrl = new URL(imageUrl)

    if (parsedUrl.hostname.endsWith("brunofritsch.cl")) {
      return `/api/image-proxy?url=${encodeURIComponent(imageUrl)}`
    }
  } catch {
    return imageUrl
  }

  return imageUrl
}
