Skip to content

Commit

Permalink
Fixes #31 (or tries to) by using a set of drastic measures.
Browse files Browse the repository at this point in the history
I'm quite sure I'll have to come back to this later one.
But for now, let's suppose it is fixed, ok ?
  • Loading branch information
Riduidel committed Sep 8, 2019
1 parent 797deb6 commit 99b2f81
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/feed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,28 @@ fn extract_authors_from_atom(entry: &AtomEntry, feed: &AtomFeed) -> Vec<String>
fn sanitize_message_authors(message_authors:Vec<String>, domain:String)->Vec<String> {
let fixed = message_authors
.iter()
.map(|author| {
trim_to_chars(author, vec!["|", ":", "-"])
})
// ni next line, we create a tuple to be used to generate the email address
.map(|author| (author, // first element of tuple is email displayed name
author.to_lowercase() // second element of tuple is generated user address
.map(|author| (author.clone(), // first element of tuple is email displayed name
author.clone().to_lowercase() // second element of tuple is generated user address
.replace(" ", "_")
.replace("&", "and")
.replace(",;:!", "")
.replace("ï", "i")
))
.map(|tuple| format!("{} <{}@{}>", tuple.0, tuple.1, domain))
.collect();
return fixed;
}

fn trim_to_chars(text:&str, characters:Vec<&str>)->String {
let mut remaining = text;
for cutter in characters {
let elements:Vec<&str> = remaining.split(cutter).collect();
remaining = elements[0].trim();
}
remaining.to_string()
}

fn find_atom_domain(feed: &AtomFeed) -> String {
return feed
.links()
Expand Down

0 comments on commit 99b2f81

Please sign in to comment.