Humanizer icon indicating copy to clipboard operation
Humanizer copied to clipboard

FixedLengthTruncator throws exception in some cases

Open bambuca opened this issue 4 months ago • 2 comments

"Short".Truncate(100, null); will throw exception:

In the Truncate method this code casues error, because value is shorter than lenght and thus value.Substring(0, legth) throws exception

https://github.com/Humanizr/Humanizer/blob/main/src/Humanizer/Truncation/FixedLengthTruncator.cs , line 21-26 if (truncationString == null || truncationString.Length > length) { return truncateFrom == TruncateFrom.Right ? value.Substring(0, length) : value.Substring(value.Length - length); }

bambuca avatar Oct 02 '24 13:10 bambuca