mirror of
https://framagit.org/veretcle/oolatoocs.git
synced 2025-07-20 12:31:18 +02:00
Merge branch 'feat_www' into 'main'
💄: remove www. from url See merge request veretcle/oolatoocs!21
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -1280,7 +1280,7 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "oolatoocs"
|
name = "oolatoocs"
|
||||||
version = "3.1.0"
|
version = "3.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atrium-api",
|
"atrium-api",
|
||||||
"bsky-sdk",
|
"bsky-sdk",
|
||||||
@@ -1435,9 +1435,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.86"
|
version = "1.0.87"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
|
checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "oolatoocs"
|
name = "oolatoocs"
|
||||||
version = "3.1.0"
|
version = "3.1.1"
|
||||||
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/bsky.rs
11
src/bsky.rs
@@ -59,10 +59,10 @@ pub async fn build_post_record(
|
|||||||
|
|
||||||
let insert_chars = "…";
|
let insert_chars = "…";
|
||||||
|
|
||||||
let re = Regex::new(r#"(https?://)(\S{1,26})(\S*)"#).unwrap();
|
let re = Regex::new(r#"(https?://)(www\.)?(\S{1,26})(\S*)"#).unwrap();
|
||||||
|
|
||||||
while let Some(found) = re.captures(&rt.text.clone()) {
|
while let Some(found) = re.captures(&rt.text.clone()) {
|
||||||
if let Some(group) = found.get(3) {
|
if let Some(group) = found.get(4) {
|
||||||
if !group.is_empty() {
|
if !group.is_empty() {
|
||||||
rt.insert(group.start(), insert_chars);
|
rt.insert(group.start(), insert_chars);
|
||||||
rt.delete(
|
rt.delete(
|
||||||
@@ -72,7 +72,8 @@ pub async fn build_post_record(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(group) = found.get(1) {
|
if let Some(group) = found.get(1) {
|
||||||
rt.delete(group.start(), group.start() + group.len());
|
let www: usize = found.get(2).map_or(0, |x| x.len());
|
||||||
|
rt.delete(group.start(), group.start() + www + group.len());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,8 +223,8 @@ mod tests {
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_build_post_record() {
|
async fn test_build_post_record() {
|
||||||
let text = "@factornews@piaille.fr Retrouvez-nous ici https://www.nintendojo.fr/articles/editos/le-mod-renovation-de-8bitdo-pour-manette-n64 et là https://www.nintendojo.fr/articles/analyses/vite-vu/vite-vu-morbid-the-lords-of-ire et un lien très court http://vsl.ie/TaMere";
|
let text = "@factornews@piaille.fr Retrouvez-nous ici https://www.nintendojo.fr/articles/editos/le-mod-renovation-de-8bitdo-pour-manette-n64 et là https://www.nintendojo.fr/articles/analyses/vite-vu/vite-vu-morbid-the-lords-of-ire et un lien très court http://vsl.ie/TaMere et un autre https://p.nintendojo.fr/w/kV3CBbKKt1nPEChHhZiNve + http://www.xxx.com + https://www.youtube.com/watch?v=dQw4w9WgXcQ&pp=ygUJcmljayByb2xs";
|
||||||
let expected_text = "@factornews@piaille.fr Retrouvez-nous ici www.nintendojo.fr/articles… et là www.nintendojo.fr/articles… et un lien très court vsl.ie/TaMere";
|
let expected_text = "@factornews@piaille.fr Retrouvez-nous ici nintendojo.fr/articles/edi… et là nintendojo.fr/articles/ana… et un lien très court vsl.ie/TaMere et un autre p.nintendojo.fr/w/kV3CBbKK… + xxx.com + youtube.com/watch?v=dQw4w9…";
|
||||||
|
|
||||||
let bsky_conf = BlueskyConfig {
|
let bsky_conf = BlueskyConfig {
|
||||||
handle: "tamerelol.bsky.social".to_string(),
|
handle: "tamerelol.bsky.social".to_string(),
|
||||||
|
Reference in New Issue
Block a user