mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-03-31 17:15:35 +00:00
fix substring extraction
This commit is contained in:
parent
68e7760b98
commit
401c4d8673
1 changed files with 6 additions and 3 deletions
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue