mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-27 16:25:36 +00:00
@@ -2,6 +2,7 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using DiscordChatExporter.Domain.Discord.Models;
|
||||
using DiscordChatExporter.Domain.Internal;
|
||||
|
||||
namespace DiscordChatExporter.Domain.Exporting
|
||||
{
|
||||
@@ -127,8 +128,7 @@ namespace DiscordChatExporter.Domain.Exporting
|
||||
buffer.Append($".{format.GetFileExtension()}");
|
||||
|
||||
// Replace invalid chars
|
||||
foreach (var invalidChar in Path.GetInvalidFileNameChars())
|
||||
buffer.Replace(invalidChar, '_');
|
||||
PathEx.EscapePath(buffer);
|
||||
|
||||
return buffer.ToString();
|
||||
}
|
||||
|
||||
@@ -27,10 +27,11 @@ namespace DiscordChatExporter.Domain.Exporting
|
||||
{
|
||||
var originalFileName = Regex.Match(url, @".+/([^?]*)").Groups[1].Value;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(originalFileName))
|
||||
return GetRandomSuffix();
|
||||
var fileName = !string.IsNullOrWhiteSpace(originalFileName) ?
|
||||
$"{Path.GetFileNameWithoutExtension(originalFileName)}-{GetRandomSuffix()}{Path.GetExtension(originalFileName)}" :
|
||||
GetRandomSuffix();
|
||||
|
||||
return $"{Path.GetFileNameWithoutExtension(originalFileName)}-{GetRandomSuffix()}{Path.GetExtension(originalFileName)}";
|
||||
return PathEx.EscapePath(fileName);
|
||||
}
|
||||
|
||||
// HACK: ConfigureAwait() is crucial here to enable sync-over-async in HtmlMessageWriter
|
||||
|
||||
Reference in New Issue
Block a user