Improve null checking for canonical URLs in JSON export

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-31 16:36:20 +00:00
parent 088236c539
commit 5a12e42f45

View file

@ -140,7 +140,10 @@ internal class JsonMessageWriter(Stream stream, ExportContext context)
); );
// Include canonical URL if a proxy URL is being used // Include canonical URL if a proxy URL is being used
if (!string.IsNullOrWhiteSpace(embedAuthor.IconProxyUrl)) if (
!string.IsNullOrWhiteSpace(embedAuthor.IconProxyUrl)
&& !string.IsNullOrWhiteSpace(embedAuthor.IconUrl)
)
{ {
_writer.WriteString("iconCanonicalUrl", embedAuthor.IconUrl); _writer.WriteString("iconCanonicalUrl", embedAuthor.IconUrl);
} }
@ -168,7 +171,10 @@ internal class JsonMessageWriter(Stream stream, ExportContext context)
); );
// Include canonical URL if a proxy URL is being used // Include canonical URL if a proxy URL is being used
if (!string.IsNullOrWhiteSpace(embedImage.ProxyUrl)) if (
!string.IsNullOrWhiteSpace(embedImage.ProxyUrl)
&& !string.IsNullOrWhiteSpace(embedImage.Url)
)
{ {
_writer.WriteString("canonicalUrl", embedImage.Url); _writer.WriteString("canonicalUrl", embedImage.Url);
} }
@ -199,7 +205,10 @@ internal class JsonMessageWriter(Stream stream, ExportContext context)
); );
// Include canonical URL if a proxy URL is being used // Include canonical URL if a proxy URL is being used
if (!string.IsNullOrWhiteSpace(embedVideo.ProxyUrl)) if (
!string.IsNullOrWhiteSpace(embedVideo.ProxyUrl)
&& !string.IsNullOrWhiteSpace(embedVideo.Url)
)
{ {
_writer.WriteString("canonicalUrl", embedVideo.Url); _writer.WriteString("canonicalUrl", embedVideo.Url);
} }
@ -232,7 +241,10 @@ internal class JsonMessageWriter(Stream stream, ExportContext context)
); );
// Include canonical URL if a proxy URL is being used // Include canonical URL if a proxy URL is being used
if (!string.IsNullOrWhiteSpace(embedFooter.IconProxyUrl)) if (
!string.IsNullOrWhiteSpace(embedFooter.IconProxyUrl)
&& !string.IsNullOrWhiteSpace(embedFooter.IconUrl)
)
{ {
_writer.WriteString("iconCanonicalUrl", embedFooter.IconUrl); _writer.WriteString("iconCanonicalUrl", embedFooter.IconUrl);
} }