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)