Skip to content

Commit

Permalink
Fixed string.Incognify not working correctly with short strings
Browse files Browse the repository at this point in the history
  • Loading branch information
RisaDev committed Jan 9, 2024
1 parent af594e7 commit dfd7493
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions CustomizePlus/Core/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Utility;
using System;

namespace CustomizePlus.Core.Extensions;

Expand All @@ -15,17 +16,22 @@ public static string Incognify(this string str)
#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)];
}
}
2 changes: 1 addition & 1 deletion CustomizePlus/CustomizePlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit dfd7493

Please sign in to comment.