From 506bc0176bf233f924faa9cbf79f0a4cd6cb20ec Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Tue, 3 Jan 2023 10:44:31 +0200 Subject: [PATCH] Fix incorrect replace order --- .../Exporting/ExportRequest.cs | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/ExportRequest.cs b/DiscordChatExporter.Core/Exporting/ExportRequest.cs index f7e251c..0ea7146 100644 --- a/DiscordChatExporter.Core/Exporting/ExportRequest.cs +++ b/DiscordChatExporter.Core/Exporting/ExportRequest.cs @@ -91,27 +91,25 @@ public partial record ExportRequest Snowflake? before = null) { // Format path - var actualOutputPath = PathEx.EscapeFileName( - Regex.Replace( - outputPath, - "%.", - m => m.Value switch - { - "%g" => guild.Id.ToString(), - "%G" => guild.Name, - "%t" => channel.Category.Id.ToString(), - "%T" => channel.Category.Name, - "%c" => channel.Id.ToString(), - "%C" => channel.Name, - "%p" => channel.Position?.ToString() ?? "0", - "%P" => channel.Category.Position?.ToString() ?? "0", - "%a" => after?.ToDate().ToString("yyyy-MM-dd") ?? "", - "%b" => before?.ToDate().ToString("yyyy-MM-dd") ?? "", - "%d" => DateTimeOffset.Now.ToString("yyyy-MM-dd"), - "%%" => "%", - _ => m.Value - } - ) + var actualOutputPath = Regex.Replace( + outputPath, + "%.", + m => PathEx.EscapeFileName(m.Value switch + { + "%g" => guild.Id.ToString(), + "%G" => guild.Name, + "%t" => channel.Category.Id.ToString(), + "%T" => channel.Category.Name, + "%c" => channel.Id.ToString(), + "%C" => channel.Name, + "%p" => channel.Position?.ToString() ?? "0", + "%P" => channel.Category.Position?.ToString() ?? "0", + "%a" => after?.ToDate().ToString("yyyy-MM-dd") ?? "", + "%b" => before?.ToDate().ToString("yyyy-MM-dd") ?? "", + "%d" => DateTimeOffset.Now.ToString("yyyy-MM-dd"), + "%%" => "%", + _ => m.Value + }) ); // Output is a directory