mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-03-31 09:05:33 +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)
|
||||
fn crop(value: String) -> String {
|
||||
const L: usize = 125; // + 3 bytes for `...` offset, 128 max @TODO optional
|
||||
if value.len() > L {
|
||||
format!("{}...", sanitize(&value[..L]))
|
||||
const C: usize = 125; // + 3 bytes for `...` offset, 128 max @TODO optional
|
||||
if value.chars().count() > C {
|
||||
format!(
|
||||
"{}...",
|
||||
sanitize(&value.chars().take(C).collect::<String>())
|
||||
)
|
||||
} else {
|
||||
value
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue