Skip to content

Commit

Permalink
fix: check for too short inputs in truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
dufkan committed May 21, 2024
1 parent fef8cc9 commit b288fcc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub fn hextrunc<T: AsRef<[u8]>>(s: T) -> String {
.as_ref()
.and_then(|x| x.parse().ok())
.unwrap_or(0);
if trunc_len == 0 {
if s.as_ref().len() <= trunc_len {
hex::encode(s.as_ref())
} else {
format!("{}...", hex::encode(&s.as_ref()[..trunc_len]))
Expand Down

0 comments on commit b288fcc

Please sign in to comment.