diff --git a/crates/uv-client/src/html.rs b/crates/uv-client/src/html.rs index 397cc014281d..bfd432337b73 100644 --- a/crates/uv-client/src/html.rs +++ b/crates/uv-client/src/html.rs @@ -108,10 +108,17 @@ impl SimpleHtml { .ok_or(Error::MissingHref)?; let href = std::str::from_utf8(href.as_bytes())?; + // Extract the hash, which should be in the fragment. let decoded = html_escape::decode_html_entities(href); let (path, hashes) = if let Some((path, fragment)) = decoded.split_once('#') { - // Extract the hash, which should be in the fragment. - (path, Self::parse_hash(fragment)?) + ( + path, + if fragment.trim().is_empty() { + Hashes::default() + } else { + Self::parse_hash(fragment)? + }, + ) } else { (href, Hashes::default()) }; @@ -455,6 +462,57 @@ mod tests { insta::assert_display_snapshot!(result, @"Missing href attribute on anchor link"); } + #[test] + fn parse_empty_fragment() { + let text = r#" + + +
+