mirror of
https://framagit.org/veretcle/oolatoocs.git
synced 2025-07-20 20:41:17 +02:00
Merge branch 'feat_better_split' into 'main'
Feat better split See merge request veretcle/oolatoocs!10
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -972,7 +972,7 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "oolatoocs"
|
name = "oolatoocs"
|
||||||
version = "1.5.2"
|
version = "1.5.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "oolatoocs"
|
name = "oolatoocs"
|
||||||
version = "1.5.2"
|
version = "1.5.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
11
src/utils.rs
11
src/utils.rs
@@ -33,19 +33,14 @@ pub fn generate_multi_tweets(content: &str) -> Option<(String, String)> {
|
|||||||
fn twitter_count(content: &str) -> usize {
|
fn twitter_count(content: &str) -> usize {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
|
|
||||||
let split_content = content.split(' ');
|
let split_content = content.split(&[' ', '\n']);
|
||||||
count += split_content.clone().count() - 1; // count the spaces
|
count += split_content.clone().count() - 1; // count the spaces
|
||||||
|
|
||||||
for word in split_content {
|
for word in split_content {
|
||||||
let cr_words = word.split('\n');
|
if word.starts_with("http://") || word.starts_with("https://") {
|
||||||
count += cr_words.clone().count() - 1; // count the chariot returns
|
|
||||||
|
|
||||||
for w in cr_words {
|
|
||||||
if w.starts_with("http://") || w.starts_with("https://") {
|
|
||||||
count += 23;
|
count += 23;
|
||||||
} else {
|
} else {
|
||||||
count += w.chars().count();
|
count += word.chars().count();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user