diff options
-rw-r--r-- | src/util.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/util.rs b/src/util.rs index 4724091..1ce5943 100644 --- a/src/util.rs +++ b/src/util.rs @@ -2,14 +2,11 @@ use crate::resp_types::{RespLoginInfo, RespMinimalAuthorInfo}; pub fn abbreviate_link(href: &str) -> &str { // Attempt to find the hostname from the URL - match href.find("://") { - Some(idx1) => match href[(idx1 + 3)..].find('/') { - Some(idx2) => Some(&href[(idx1 + 3)..(idx1 + 3 + idx2)]), - None => None, - }, - None => None, - } - .unwrap_or(href) + href.find("://") + .and_then(|idx1| { + href[(idx1 + 3)..].find('/').map(|idx2| &href[(idx1 + 3)..(idx1 + 3 + idx2)]) + }) + .unwrap_or(href) } pub fn author_is_me( |