From 088236c5396189beceada61c07453941411fa68a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 16:33:42 +0000 Subject: [PATCH] Add canonical URL preservation for embed assets in HTML and JSON exports Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> --- .../Exporting/JsonMessageWriter.cs | 24 +++++++++++++++++ .../Exporting/MessageGroupTemplate.cshtml | 27 +++++++++++++------ 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs index 5b1dfe48..2ffa4364 100644 --- a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs +++ b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs @@ -138,6 +138,12 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); + + // Include canonical URL if a proxy URL is being used + if (!string.IsNullOrWhiteSpace(embedAuthor.IconProxyUrl)) + { + _writer.WriteString("iconCanonicalUrl", embedAuthor.IconUrl); + } } _writer.WriteEndObject(); @@ -160,6 +166,12 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); + + // Include canonical URL if a proxy URL is being used + if (!string.IsNullOrWhiteSpace(embedImage.ProxyUrl)) + { + _writer.WriteString("canonicalUrl", embedImage.Url); + } } _writer.WriteNumber("width", embedImage.Width); @@ -185,6 +197,12 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); + + // Include canonical URL if a proxy URL is being used + if (!string.IsNullOrWhiteSpace(embedVideo.ProxyUrl)) + { + _writer.WriteString("canonicalUrl", embedVideo.Url); + } } _writer.WriteNumber("width", embedVideo.Width); @@ -212,6 +230,12 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); + + // Include canonical URL if a proxy URL is being used + if (!string.IsNullOrWhiteSpace(embedFooter.IconProxyUrl)) + { + _writer.WriteString("iconCanonicalUrl", embedFooter.IconUrl); + } } _writer.WriteEndObject(); diff --git a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml index e0730553..ffeaa745 100644 --- a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml @@ -388,7 +388,7 @@