mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-23 19:26:57 -04:00
parent
47a1518cd9
commit
1fe4ecb3af
2 changed files with 6 additions and 1 deletions
|
@ -46,7 +46,7 @@ namespace DiscordChatExporter.Domain.Exporting
|
||||||
var originalFileName = Regex.Match(url, @".+/([^?]*)").Groups[1].Value;
|
var originalFileName = Regex.Match(url, @".+/([^?]*)").Groups[1].Value;
|
||||||
|
|
||||||
var fileName = !string.IsNullOrWhiteSpace(originalFileName)
|
var fileName = !string.IsNullOrWhiteSpace(originalFileName)
|
||||||
? originalFileName
|
? $"{Path.GetFileNameWithoutExtension(originalFileName).Truncate(50)}{Path.GetExtension(originalFileName)}"
|
||||||
: GetRandomFileName();
|
: GetRandomFileName();
|
||||||
|
|
||||||
return PathEx.EscapePath(fileName);
|
return PathEx.EscapePath(fileName);
|
||||||
|
|
|
@ -4,6 +4,11 @@ namespace DiscordChatExporter.Domain.Internal.Extensions
|
||||||
{
|
{
|
||||||
internal static class StringExtensions
|
internal static class StringExtensions
|
||||||
{
|
{
|
||||||
|
public static string Truncate(this string str, int charCount) =>
|
||||||
|
str.Length > charCount
|
||||||
|
? str.Substring(0, charCount)
|
||||||
|
: str;
|
||||||
|
|
||||||
public static StringBuilder AppendIfNotEmpty(this StringBuilder builder, char value) =>
|
public static StringBuilder AppendIfNotEmpty(this StringBuilder builder, char value) =>
|
||||||
builder.Length > 0
|
builder.Length > 0
|
||||||
? builder.Append(value)
|
? builder.Append(value)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue