From 27c0d60812719e628367bf71cb53989ef454e323 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 16:50:20 +0000 Subject: [PATCH] Remove conditional checks for canonical URLs in HTML and JSON exports Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> --- .../Exporting/JsonMessageWriter.cs | 28 +++---------------- .../Exporting/MessageGroupTemplate.cshtml | 26 ++++++++--------- 2 files changed, 15 insertions(+), 39 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs index cf3ee38d..1b90ec02 100644 --- a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs +++ b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs @@ -138,12 +138,7 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); - - // Include canonical URL if present - if (!string.IsNullOrWhiteSpace(embedAuthor.IconUrl)) - { - _writer.WriteString("iconCanonicalUrl", embedAuthor.IconUrl); - } + _writer.WriteString("iconCanonicalUrl", embedAuthor.IconUrl); } _writer.WriteEndObject(); @@ -166,12 +161,7 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); - - // Include canonical URL if present - if (!string.IsNullOrWhiteSpace(embedImage.Url)) - { - _writer.WriteString("canonicalUrl", embedImage.Url); - } + _writer.WriteString("canonicalUrl", embedImage.Url); } _writer.WriteNumber("width", embedImage.Width); @@ -197,12 +187,7 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); - - // Include canonical URL if present - if (!string.IsNullOrWhiteSpace(embedVideo.Url)) - { - _writer.WriteString("canonicalUrl", embedVideo.Url); - } + _writer.WriteString("canonicalUrl", embedVideo.Url); } _writer.WriteNumber("width", embedVideo.Width); @@ -230,12 +215,7 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); - - // Include canonical URL if present - if (!string.IsNullOrWhiteSpace(embedFooter.IconUrl)) - { - _writer.WriteString("iconCanonicalUrl", embedFooter.IconUrl); - } + _writer.WriteString("iconCanonicalUrl", embedFooter.IconUrl); } _writer.WriteEndObject(); diff --git a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml index ffeaa745..e27fad2b 100644 --- a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml @@ -388,7 +388,7 @@
@if (!string.IsNullOrWhiteSpace(embed.Author.IconUrl)) { - Author icon + Author icon } @if (!string.IsNullOrWhiteSpace(embed.Author.Name)) @@ -442,13 +442,11 @@ embed.Url; var embedImageCanonicalUrl = - (embed.Image?.ProxyUrl is not null && embed.Image?.Url is not null) ? embed.Image?.Url : - (embed.Thumbnail?.ProxyUrl is not null && embed.Thumbnail?.Url is not null) ? embed.Thumbnail?.Url : - null; + embed.Image?.Url ?? embed.Thumbnail?.Url ?? embed.Url;
- Embedded image + Embedded image
} @@ -462,11 +460,10 @@ embed.Video?.ProxyUrl ?? embed.Video?.Url ?? embed.Url; - var embedVideoCanonicalUrl = - embed.Video?.ProxyUrl is not null && embed.Video?.Url is not null ? embed.Video?.Url : null; + var embedVideoCanonicalUrl = embed.Video?.Url ?? embed.Url;
-
@@ -478,11 +475,10 @@ embed.Video?.ProxyUrl ?? embed.Video?.Url ?? embed.Url; - var embedVideoCanonicalUrl = - embed.Video?.ProxyUrl is not null && embed.Video?.Url is not null ? embed.Video?.Url : null; + var embedVideoCanonicalUrl = embed.Video?.Url ?? embed.Url;
-
@@ -510,7 +506,7 @@
@if (!string.IsNullOrWhiteSpace(embed.Author.IconUrl)) { - Author icon + Author icon } @if (!string.IsNullOrWhiteSpace(embed.Author.Name)) @@ -585,7 +581,7 @@ { } @@ -601,7 +597,7 @@ { } @@ -616,7 +612,7 @@ @* Footer icon *@ @if (!string.IsNullOrWhiteSpace(embed.Footer?.IconUrl)) { - Footer icon + Footer icon }