From 5a12e42f450c2cdfe7b9daa4ad0a980ac6f509d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 16:36:20 +0000 Subject: [PATCH] Improve null checking for canonical URLs in JSON export Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> --- .../Exporting/JsonMessageWriter.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs index 2ffa4364..25420b75 100644 --- a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs +++ b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs @@ -140,7 +140,10 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) ); // 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); } @@ -168,7 +171,10 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) ); // 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); } @@ -199,7 +205,10 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) ); // 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); } @@ -232,7 +241,10 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) ); // 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); }