mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-24 02:03:54 +00:00
Add file:// protocol to absolute asset paths in HTML exports (#1475)
* Initial plan * Add file:// protocol prefix to absolute paths in HTML exports Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> * Improve absolute path detection for cross-platform compatibility Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> * Remove unused System.IO import Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> * Use Path.IsPathFullyQualified for absolute path detection (fixes #1473) Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace DiscordChatExporter.Core.Utils;
|
||||
@@ -10,6 +11,19 @@ public static class Url
|
||||
var buffer = new StringBuilder();
|
||||
var position = 0;
|
||||
|
||||
// For absolute paths, prepend file:// protocol for proper browser handling
|
||||
if (Path.IsPathFullyQualified(filePath))
|
||||
{
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user