Skip to content

Commit

Permalink
imp - Zero threshold in Truncate() returns empty string
Browse files Browse the repository at this point in the history
---

The threshold of zero or less than zero should return an empty string.

---

Type: imp
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Jan 28, 2024
1 parent de8981c commit 4944c90
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Textify/General/TextTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ public static string Truncate(this string target, int threshold)
{
if (target is null)
throw new TextifyException("The target may not be null");
if (threshold < 0)
threshold = 0;
if (threshold == 0)
return "";

// Try to truncate string. If the string length is bigger than the threshold, it'll be truncated to the length of
// the threshold, putting three dots next to it. We don't use ellipsis marks here because we're dealing with the
Expand Down

0 comments on commit 4944c90

Please sign in to comment.