pub(crate) fn extract_authority(url: &mut Url) -> Option<(String, Option<String>)> {
    use percent_encoding::percent_decode;

    if url.has_authority() {
        let username: String = percent_decode(url.username().as_bytes())
            .decode_utf8()
            .ok()?
            .into();
        let password = url.password().and_then(|pass| {
            percent_decode(pass.as_bytes())
                .decode_utf8()
                .ok()
                .map(String::from)
        });
        if !username.is_empty() || password.is_some() {
            url
                .set_username("")
                .expect("has_authority means set_username shouldn't fail");
            url
                .set_password(None)
                .expect("has_authority means set_password shouldn't fail");
            return Some((username, password))
        }
    }

    None
}
/// Check the request URL for a "username:password" type authority, and if
/// found, remove it from the URL and return it.
Check the request URL for a "username:password" type authority, and if
found, remove it from the URL and return it.
Check the request URL for a " username : password " type authority and if found remove it from the URL and return it .
pub(crate) fn extract_authority(url: &mut Url) -> Option<(String, Option<String>)> {
    use percent_encoding::percent_decode;
    if url.has_authority() {
        let username: String = percent_decode(url.username().as_bytes())
            .decode_utf8()
            .ok()?
            .into();
        let password = url.password().and_then(|pass| {
            percent_decode(pass.as_bytes())
                .decode_utf8()
                .ok()
                .map(String::from)
        });
        if !username.is_empty() || password.is_some() {
            url
                .set_username("")
                .expect("has_authority means set_username shouldn't fail");
            url
                .set_password(None)
                .expect("has_authority means set_password shouldn't fail");
            return Some((username, password))
        }
    }
    None
}
pub ( crate ) fn extract_authority ( url : & mut Url ) -> Option < ( String , Option < String > ) > { use percent_encoding :: percent_decode ; if url . has_authority ( ) { let username : String = percent_decode ( url . username ( ) . as_bytes ( ) ) . decode_utf8 ( ) . ok ( ) ? . into ( ) ; let password = url . password ( ) . and_then ( | pass | { percent_decode ( pass . as_bytes ( ) ) . decode_utf8 ( ) . ok ( ) . map ( String :: from ) } ) ; if ! username . is_empty ( ) || password . is_some ( ) { url . set_username ( " " ) . expect ( " " ) ; url . set_password ( None ) . expect ( " " ) ; return Some ( ( username , password ) ) } } None }
Check the request URL for a "username:password" type authority, and if
found, remove it from the URL and return it.
Check the request URL for a " username : password " type authority and if found remove it from the URL and return it .
url
&mut Url
url
&mut Url