Fixed string.Incognify not working correctly with short strings

This commit is contained in:
RisaDev
2024-01-10 01:20:43 +03:00
parent af594e7c4f
commit dfd74933c7
2 changed files with 13 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
using Dalamud.Utility;
using System;
namespace CustomizePlus.Core.Extensions;
@@ -15,17 +16,22 @@ internal static class StringExtensions
#if !INCOGNIFY_STRINGS
return str;
#endif
if (str.Contains(" "))
{
var split = str.Split(' ');
if (split.Length > 2)
return $"{str[..5]}...";
return $"{split[0][0]}.{split[1][0]}";
if (split.Length == 2)
return $"{split[0][0]}.{split[1][0]}";
}
return $"{str[..5]}...";
return str.GetCutString();
}
private static string GetCutString(this string str, int maxLength = 5)
{
if(str.Length > maxLength)
return $"{str[..maxLength]}...";
else
return str[0..Math.Min(str.Length, maxLength)];
}
}

View File

@@ -4,7 +4,7 @@
<PropertyGroup>
<Authors></Authors>
<Company></Company>
<Version>2.0.0.1</Version>
<Version>2.0.0.2</Version>
<Description>Customize+</Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/Aether-Tools/CustomizePlus</PackageProjectUrl>