fix substring extraction

This commit is contained in:
yggverse 2025-07-09 17:05:14 +03:00
parent 68e7760b98
commit 401c4d8673

View file

@ -54,9 +54,12 @@ fn filter_list(value: Option<Vec<(String, u64)>>) -> Option<Vec<(String, u64)>>
/// Crop long values (prevents unexpected memory pool usage) /// Crop long values (prevents unexpected memory pool usage)
fn crop(value: String) -> String { fn crop(value: String) -> String {
const L: usize = 125; // + 3 bytes for `...` offset, 128 max @TODO optional const C: usize = 125; // + 3 bytes for `...` offset, 128 max @TODO optional
if value.len() > L { if value.chars().count() > C {
format!("{}...", sanitize(&value[..L])) format!(
"{}...",
sanitize(&value.chars().take(C).collect::<String>())
)
} else { } else {
value value
} }