Skip to content

Commit ba9b695

Browse files
committed
Fix for truncateMessage function
1 parent ca77c86 commit ba9b695

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

internal/txlib/utils.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ func truncateMessage(message string) string {
225225
maxLength = 0
226226
}
227227

228-
if len(message) > maxLength {
229-
return message[:maxLength-2] + ".."
228+
if len(message) > maxLength && maxLength > 0 {
229+
return message[:maxLength] + ".."
230230
}
231231
return message
232232
}

internal/txlib/utils_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestTruncateMessage(t *testing.T) {
8686
)
8787
assert.Equal(
8888
t,
89-
"this is a long message that needs to be truncated because it exceeds the max..",
89+
"this is a long message that needs to be truncated because it exceeds the maxim..",
9090
result,
9191
)
9292

0 commit comments

Comments
 (0)