Add file:// protocol prefix to absolute paths in HTML exports

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-12 09:20:02 +00:00
parent a7517e4b9c
commit 63b71d9945

View file

@ -1,4 +1,5 @@
using System; using System;
using System.IO;
using System.Text; using System.Text;
namespace DiscordChatExporter.Core.Utils; namespace DiscordChatExporter.Core.Utils;
@ -10,6 +11,22 @@ public static class Url
var buffer = new StringBuilder(); var buffer = new StringBuilder();
var position = 0; 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) while (true)
{ {
if (position >= filePath.Length) if (position >= filePath.Length)