From aa5c338086f575ed62f799ea2ad726c2a6481ee4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 09:22:26 +0000 Subject: [PATCH] Improve absolute path detection for cross-platform compatibility Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> --- DiscordChatExporter.Core/Utils/Url.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/DiscordChatExporter.Core/Utils/Url.cs b/DiscordChatExporter.Core/Utils/Url.cs index 1250c604..21f3017d 100644 --- a/DiscordChatExporter.Core/Utils/Url.cs +++ b/DiscordChatExporter.Core/Utils/Url.cs @@ -11,8 +11,13 @@ public static class Url var buffer = new StringBuilder(); var position = 0; - // Check if the path is absolute - var isAbsolute = Path.IsPathRooted(filePath); + // Check if the path is absolute (either Unix-style or Windows-style) + // Unix: starts with / + // Windows: starts with drive letter followed by colon (e.g., C:) + var isUnixAbsolute = filePath.StartsWith('/') || filePath.StartsWith('\\'); + var isWindowsAbsolute = + filePath.Length >= 2 && char.IsLetter(filePath[0]) && filePath[1] == ':'; + var isAbsolute = isUnixAbsolute || isWindowsAbsolute; // For absolute paths, prepend file:// protocol for proper browser handling if (isAbsolute) @@ -21,7 +26,7 @@ public static class Url // 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('\\')) + if (isWindowsAbsolute) { buffer.Append('/'); }