Skip to content

Commit

Permalink
Fix bug with too-long substrings (#350)
Browse files Browse the repository at this point in the history
C#'s string.Substring method throws an exception if length is beyond
the end of the string, so we need to check the string length first.
  • Loading branch information
rmunn authored Oct 17, 2024
1 parent d41ad26 commit f4bdb42
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/LfMerge.Core/Reporting/ConversionError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public string MongoId() {
}

public string Label() {
if (Comment == null || Comment.Content == null) return string.Empty;
if (Comment == null || String.IsNullOrEmpty(Comment.Content)) return string.Empty;
if (Comment.Content.Length < 100) return Comment.Content;
return Comment.Content.Substring(0, 100);
}
}
Expand Down

0 comments on commit f4bdb42

Please sign in to comment.