webpage_quality_analyzer 1.0.2

High-performance webpage quality analyzer with 115 comprehensive metrics - Rust library with WASM, C++, and Python bindings
Documentation
use url::Url;

/// Resolve a raw href against a base URL.
///
/// - If `raw_href` is an absolute URL, return it directly.
/// - Otherwise, resolve it relative to `base_url`.
/// - Returns `None` if parsing or resolution fails.
pub fn resolve_url(raw_href: &str, base_url: &str) -> Option<String> {
    // If raw_href is already an absolute URL, try parsing directly
    if let Ok(abs_url) = Url::parse(raw_href) {
        return Some(abs_url.into());
    }

    // Otherwise resolve relative to base_url
    match Url::parse(base_url).and_then(|base| base.join(raw_href)) {
        Ok(resolved) => Some(resolved.into()),
        Err(_) => None,
    }
}