From 63b71d9945977ea7d66bfd0e9fbcef55ec829565 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 09:20:02 +0000 Subject: [PATCH] Add file:// protocol prefix to absolute paths in HTML exports Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> --- DiscordChatExporter.Core/Utils/Url.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/DiscordChatExporter.Core/Utils/Url.cs b/DiscordChatExporter.Core/Utils/Url.cs index 9ccbd30d..1250c604 100644 --- a/DiscordChatExporter.Core/Utils/Url.cs +++ b/DiscordChatExporter.Core/Utils/Url.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Text; namespace DiscordChatExporter.Core.Utils; @@ -10,6 +11,22 @@ public static class Url var buffer = new StringBuilder(); var position = 0; + // Check if the path is absolute + var isAbsolute = Path.IsPathRooted(filePath); + + // For absolute paths, prepend file:// protocol for proper browser handling + if (isAbsolute) + { + buffer.Append("file://"); + + // On Windows, we need to add an extra slash before the drive letter + // e.g., file:///C:/path instead of file://C:/path + if (!filePath.StartsWith('/') && !filePath.StartsWith('\\')) + { + buffer.Append('/'); + } + } + while (true) { if (position >= filePath.Length)