~vpzom/hitide

2cb08f84335e77d31cd0168eaff99289ea48aa3d — Matthias Beyer 4 months ago ef36a05
Cleanup: Replace nested matches with method chaining

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
1 files changed, 5 insertions(+), 8 deletions(-)

M src/util.rs
M src/util.rs => src/util.rs +5 -8
@@ 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(