fn possible_blob_storage_url(url: &Url, container: bool) -> bool {
    if url.scheme() == "file" {
        return true;
    }

    if url.scheme() != "https" {
        return false;
    }

    // Must have a domain name, not an IP address.
    if url.domain().is_none() {
        return false;
    }

    // Rough check that we have at least have one subdomain.
    //
    // Unwrap ok due to last check.
    if !url.domain().unwrap().contains('.') {
        return false;
    }

    match url.path_segments() {
        Some(segments) => {
            let segments: Vec<_> = segments.collect();

            match segments.len() {
                // We always require _at least_ a container name.
                0 => return false,
                // If we aren't checking for a container URL, then there
                // should be at least 2 segments: 1 for the container, 1
                // or more for the blob name.
                1 => {
                    if !container {
                        return false;
                    }
                }
                // In this case, `n > 1`, and container blobs must have
                // _exactly_ 1 segment (the container name).
                _n => {
                    if container {
                        return false;
                    }
                }
            }

            // The container path segment must always be nonempty.
            //
            // If here, `segments.len() > 0`.
            if segments[0].is_empty() {
                return false;
            }
        }
        None => {
            return false;
        }
    }

    true
}
// Weak check of necessary conditions for a storage blob or container URL.
Weak check of necessary conditions for a storage blob or container URL.
Weak check of necessary conditions for a storage blob or container URL .
fn possible_blob_storage_url(url: &Url, container: bool) -> bool {
    if url.scheme() == "file" {
        return true;
    }
    if url.scheme() != "https" {
        return false;
    }
    // Must have a domain name, not an IP address.
    if url.domain().is_none() {
        return false;
    }
    // Rough check that we have at least have one subdomain.
    //
    // Unwrap ok due to last check.
    if !url.domain().unwrap().contains('.') {
        return false;
    }
    match url.path_segments() {
        Some(segments) => {
            let segments: Vec<_> = segments.collect();
            match segments.len() {
                // We always require _at least_ a container name.
                0 => return false,
                // If we aren't checking for a container URL, then there
                // should be at least 2 segments: 1 for the container, 1
                // or more for the blob name.
                1 => {
                    if !container {
                        return false;
                    }
                }
                // In this case, `n > 1`, and container blobs must have
                // _exactly_ 1 segment (the container name).
                _n => {
                    if container {
                        return false;
                    }
                }
            }
            // The container path segment must always be nonempty.
            //
            // If here, `segments.len() > 0`.
            if segments[0].is_empty() {
                return false;
            }
        }
        None => {
            return false;
        }
    }
    true
}
fn possible_blob_storage_url ( url : & Url , container : bool ) -> bool { if url . scheme ( ) == " " { return true ; } if url . scheme ( ) != " " { return false ; } // Must have a domain name, not an IP address. if url . domain ( ) . is_none ( ) { return false ; } // Rough check that we have at least have one subdomain. // // Unwrap ok due to last check. if ! url . domain ( ) . unwrap ( ) . contains ( '.' ) { return false ; } match url . path_segments ( ) { Some ( segments ) => { let segments : Vec < _ > = segments . collect ( ) ; match segments . len ( ) { // We always require _at least_ a container name. 0 => return false , // If we aren't checking for a container URL, then there // should be at least 2 segments: 1 for the container, 1 // or more for the blob name. 1 => { if ! container { return false ; } } // In this case, `n > 1`, and container blobs must have // _exactly_ 1 segment (the container name). _n => { if container { return false ; } } } // The container path segment must always be nonempty. // // If here, `segments.len() > 0`. if segments [ 0 ] . is_empty ( ) { return false ; } } None => { return false ; } } true }
Weak check of necessary conditions for a storage blob or container URL.
Weak check of necessary conditions for a storage blob or container URL .
url
&Url
container
bool