diff --git a/desktop/src/shared/ui/link-preview-attachment.tsx b/desktop/src/shared/ui/link-preview-attachment.tsx index 136a02ab3..8f789dec7 100644 --- a/desktop/src/shared/ui/link-preview-attachment.tsx +++ b/desktop/src/shared/ui/link-preview-attachment.tsx @@ -112,6 +112,14 @@ function LinkPreviewLogo({ preview }: { preview: ResolvedLinkPreview }) { } } +function getHostname(preview: ResolvedLinkPreview): string { + try { + return new URL(preview.href).hostname.replace(/^www\./, ""); + } catch { + return preview.provider; + } +} + export function LinkPreviewAttachment({ className, onRemove, @@ -123,6 +131,7 @@ export function LinkPreviewAttachment({ }) { const reserveImage = preview.imageState !== "none"; const showImage = preview.imageState === "image"; + const hostname = getHostname(preview); return (