mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
refactor: eliminate indexing in compute_mailinglist_name
This commit is contained in:
@@ -2465,14 +2465,16 @@ async fn create_or_lookup_mailinglist(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::indexing_slicing)]
|
|
||||||
fn compute_mailinglist_name(
|
fn compute_mailinglist_name(
|
||||||
list_id_header: &str,
|
list_id_header: &str,
|
||||||
listid: &str,
|
listid: &str,
|
||||||
mime_parser: &MimeMessage,
|
mime_parser: &MimeMessage,
|
||||||
) -> String {
|
) -> String {
|
||||||
let mut name = match LIST_ID_REGEX.captures(list_id_header) {
|
let mut name = match LIST_ID_REGEX
|
||||||
Some(cap) => cap[1].trim().to_string(),
|
.captures(list_id_header)
|
||||||
|
.and_then(|caps| caps.get(1))
|
||||||
|
{
|
||||||
|
Some(cap) => cap.as_str().trim().to_string(),
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2519,8 +2521,11 @@ fn compute_mailinglist_name(
|
|||||||
// 51231231231231231231231232869f58.xing.com -> xing.com
|
// 51231231231231231231231232869f58.xing.com -> xing.com
|
||||||
static PREFIX_32_CHARS_HEX: Lazy<Regex> =
|
static PREFIX_32_CHARS_HEX: Lazy<Regex> =
|
||||||
Lazy::new(|| Regex::new(r"([0-9a-fA-F]{32})\.(.{6,})").unwrap());
|
Lazy::new(|| Regex::new(r"([0-9a-fA-F]{32})\.(.{6,})").unwrap());
|
||||||
if let Some(cap) = PREFIX_32_CHARS_HEX.captures(listid) {
|
if let Some(cap) = PREFIX_32_CHARS_HEX
|
||||||
name = cap[2].to_string();
|
.captures(listid)
|
||||||
|
.and_then(|caps| caps.get(2))
|
||||||
|
{
|
||||||
|
name = cap.as_str().to_string();
|
||||||
} else {
|
} else {
|
||||||
name = listid.to_string();
|
name = listid.to_string();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user