pub(crate) fn extract_links_from_elem_attr(
    attr_name: &str,
    elem_name: &str,
    attr_value: &str,
) -> Vec<String> {
    // See a comprehensive list of attributes that might contain URLs/URIs
    // over at: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
    let mut urls = Vec::new();

    match (attr_name, elem_name) {
        ("href" | "src" | "cite", _) | ("data", "object") | ("onhashchange", "body") => {
            urls.push(attr_value.to_owned());
        }
        ("srcset", _) => {
            for image_candidate_string in attr_value.trim().split(',') {
                for part in image_candidate_string.split_ascii_whitespace() {
                    if part.is_empty() {
                        continue;
                    }

                    urls.push(part.to_owned());
                    break;
                }
            }
        }
        _ => (),
    }

    urls
}
/// Extract all semantically-known links from a given html attribute. Pattern-based extraction from
/// unstructured plaintext is done elsewhere.
Extract all semantically-known links from a given html attribute. Pattern-based extraction from
unstructured plaintext is done elsewhere.
Extract all semantically - known links from a given html attribute . Pattern - based extraction from unstructured plaintext is done elsewhere .
pub(crate) fn extract_links_from_elem_attr(
    attr_name: &str,
    elem_name: &str,
    attr_value: &str,
) -> Vec<String> {
    // See a comprehensive list of attributes that might contain URLs/URIs
    // over at: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
    let mut urls = Vec::new();
    match (attr_name, elem_name) {
        ("href" | "src" | "cite", _) | ("data", "object") | ("onhashchange", "body") => {
            urls.push(attr_value.to_owned());
        }
        ("srcset", _) => {
            for image_candidate_string in attr_value.trim().split(',') {
                for part in image_candidate_string.split_ascii_whitespace() {
                    if part.is_empty() {
                        continue;
                    }
                    urls.push(part.to_owned());
                    break;
                }
            }
        }
        _ => (),
    }
    urls
}
pub ( crate ) fn extract_links_from_elem_attr ( attr_name : & str , elem_name : & str , attr_value : & str , ) -> Vec < String > { // See a comprehensive list of attributes that might contain URLs/URIs // over at: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes let mut urls = Vec :: new ( ) ; match ( attr_name , elem_name ) { ( " " | " " | " " , _ ) | ( " " , " " ) | ( " " , " " ) => { urls . push ( attr_value . to_owned ( ) ) ; } ( " " , _ ) => { for image_candidate_string in attr_value . trim ( ) . split ( ',' ) { for part in image_candidate_string . split_ascii_whitespace ( ) { if part . is_empty ( ) { continue ; } urls . push ( part . to_owned ( ) ) ; break ; } } } _ => ( ) , } urls }
Extract all semantically-known links from a given html attribute.
Extract all semantically - known links from a given html attribute .
attr_name
&str
elem_name
&str
attr_value
&str