pub fn canonicalize_url(url: &Url) -> Url {
    let mut url = url.clone();

    // Strip a trailing slash
    url.path_segments_mut().unwrap().pop_if_empty();

    // HACKHACK: For github URL's specifically just lowercase
    // everything.  GitHub treats both the same, but they hash
    // differently, and we're gonna be hashing them. This wants a more
    // general solution, and also we're almost certainly not using the
    // same case conversion rules that GitHub does. (#84)
    if url.host_str() == Some("github.com") {
        url.set_scheme("https").unwrap();
        let path = url.path().to_lowercase();
        url.set_path(&path);
    }

    // Repos generally can be accessed with or w/o '.git'
    let needs_chopping = url.path().ends_with(".git");
    if needs_chopping {
        let last = {
            let last = url.path_segments().unwrap().next_back().unwrap();
            last[..last.len() - 4].to_owned()
        };
        url.path_segments_mut().unwrap().pop().push(&last);
    }

    url
}
// Some hacks and heuristics for making equivalent URLs hash the same
Some hacks and heuristics for making equivalent URLs hash the same
Some hacks and heuristics for making equivalent URLs hash the same
pub fn canonicalize_url(url: &Url) -> Url {
    let mut url = url.clone();
    // Strip a trailing slash
    url.path_segments_mut().unwrap().pop_if_empty();
    // HACKHACK: For github URL's specifically just lowercase
    // everything.  GitHub treats both the same, but they hash
    // differently, and we're gonna be hashing them. This wants a more
    // general solution, and also we're almost certainly not using the
    // same case conversion rules that GitHub does. (#84)
    if url.host_str() == Some("github.com") {
        url.set_scheme("https").unwrap();
        let path = url.path().to_lowercase();
        url.set_path(&path);
    }
    // Repos generally can be accessed with or w/o '.git'
    let needs_chopping = url.path().ends_with(".git");
    if needs_chopping {
        let last = {
            let last = url.path_segments().unwrap().next_back().unwrap();
            last[..last.len() - 4].to_owned()
        };
        url.path_segments_mut().unwrap().pop().push(&last);
    }
    url
}
pub fn canonicalize_url ( url : & Url ) -> Url { let mut url = url . clone ( ) ; // Strip a trailing slash url . path_segments_mut ( ) . unwrap ( ) . pop_if_empty ( ) ; // HACKHACK: For github URL's specifically just lowercase // everything.  GitHub treats both the same, but they hash // differently, and we're gonna be hashing them. This wants a more // general solution, and also we're almost certainly not using the // same case conversion rules that GitHub does. (#84) if url . host_str ( ) == Some ( " " ) { url . set_scheme ( " " ) . unwrap ( ) ; let path = url . path ( ) . to_lowercase ( ) ; url . set_path ( & path ) ; } // Repos generally can be accessed with or w/o '.git' let needs_chopping = url . path ( ) . ends_with ( " " ) ; if needs_chopping { let last = { let last = url . path_segments ( ) . unwrap ( ) . next_back ( ) . unwrap ( ) ; last [ .. last . len ( ) - 4 ] . to_owned ( ) } ; url . path_segments_mut ( ) . unwrap ( ) . pop ( ) . push ( & last ) ; } url }
Some hacks and heuristics for making equivalent URLs hash the same
Some hacks and heuristics for making equivalent URLs hash the same
url
&Url
url
&Url