diff --git a/crates/uv-pep508/src/lib.rs b/crates/uv-pep508/src/lib.rs index e2f432bbc..8668a9e52 100644 --- a/crates/uv-pep508/src/lib.rs +++ b/crates/uv-pep508/src/lib.rs @@ -933,7 +933,7 @@ fn parse_pep508_requirement( // // See: https://github.com/pypa/pip/blob/111eed14b6e9fba7c78a5ec2b7594812d17b5d2b/src/pip/_internal/utils/filetypes.py#L8 if requirement_kind.is_none() { - if looks_like_archive(cursor.slice(name_start, name_end)) { + if looks_like_archive(cursor.slice(name_start, name_end - name_start)) { let clone = cursor.clone().at(start); return Err(Pep508Error { message: Pep508ErrorSource::UnsupportedRequirement("URL requirement must be preceded by a package name. Add the name of the package before the URL (e.g., `package_name @ https://...`).".to_string()), diff --git a/crates/uv-pep508/src/tests.rs b/crates/uv-pep508/src/tests.rs index 661fedb18..970202ff4 100644 --- a/crates/uv-pep508/src/tests.rs +++ b/crates/uv-pep508/src/tests.rs @@ -116,6 +116,12 @@ fn basic_examples() { assert_eq!(requests, expected); } +#[test] +fn leading_whitespace() { + let numpy = Requirement::::from_str(" numpy").unwrap(); + assert_eq!(numpy.name.as_ref(), "numpy"); +} + #[test] fn parenthesized_single() { let numpy = Requirement::::from_str("numpy ( >=1.19 )").unwrap();