Annotation For src/utils.rs
Logged in as anonymous

Origin for each line in src/utils.rs from check-in dafeec0481:

f5ed284f8c 2025-06-21    1: use crate::Cursor;
f5ed284f8c 2025-06-21    2: 
f5ed284f8c 2025-06-21    3: use lazy_static::lazy_static;
f5ed284f8c 2025-06-21    4: use regex::Regex;
0f47e23e21 2026-01-12    5: use stacked_errors::{
0f47e23e21 2026-01-12    6: 	bail,
0f47e23e21 2026-01-12    7: 	Result,
0f47e23e21 2026-01-12    8: };
f5ed284f8c 2025-06-21    9: 
f5ed284f8c 2025-06-21   10: lazy_static! {
f5ed284f8c 2025-06-21   11: 	pub static ref RE_DOMAIN: Regex = Regex::new(r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$").unwrap();
dafeec0481 2026-01-18   12: 	pub static ref RE_CLOSING: Regex = Regex::new(r"</[ \t]*(pre|code)[ \t]*>").unwrap();
f5ed284f8c 2025-06-21   13: }
f5ed284f8c 2025-06-21   14: 
f5ed284f8c 2025-06-21   15: /// `Attachment` object to store number attachment data and corresponding file name
f5ed284f8c 2025-06-21   16: #[derive(Debug)]
f5ed284f8c 2025-06-21   17: pub struct Attachment {
f5ed284f8c 2025-06-21   18: 	pub data: Cursor<Vec<u8>>,
f5ed284f8c 2025-06-21   19: 	pub name: String,
0f47e23e21 2026-01-12   20: }
0f47e23e21 2026-01-12   21: 
dafeec0481 2026-01-18   22: /// Pass any text here to be validated as not breaking from Telegram preformatted blocks
0f47e23e21 2026-01-12   23: pub fn validate (text: &str) -> Result<&str> {
dafeec0481 2026-01-18   24: 	if RE_CLOSING.is_match(text) {
dafeec0481 2026-01-18   25: 		bail!("Telegram closing tag found.");
dafeec0481 2026-01-18   26: 	} else {
dafeec0481 2026-01-18   27: 		Ok(text)
dafeec0481 2026-01-18   28: 	}
f5ed284f8c 2025-06-21   29: }