diff --git a/crates/uv-client/src/error.rs b/crates/uv-client/src/error.rs index 6d2c2baea..c873e6a6a 100644 --- a/crates/uv-client/src/error.rs +++ b/crates/uv-client/src/error.rs @@ -137,6 +137,9 @@ pub enum ErrorKind { #[error("Expected a file URL, but received: {0}")] NonFileUrl(Url), + #[error("Expected an index URL, but received non-base URL: {0}")] + CannotBeABase(Url), + #[error(transparent)] DistInfo(#[from] install_wheel_rs::Error), diff --git a/crates/uv-client/src/registry_client.rs b/crates/uv-client/src/registry_client.rs index b758994e9..acd003931 100644 --- a/crates/uv-client/src/registry_client.rs +++ b/crates/uv-client/src/registry_client.rs @@ -270,7 +270,7 @@ impl RegistryClient { // Format the URL for PyPI. let mut url: Url = index.clone().into(); url.path_segments_mut() - .unwrap() + .map_err(|()| ErrorKind::CannotBeABase(index.clone().into()))? .pop_if_empty() .push(package_name.as_ref()) // The URL *must* end in a trailing slash for proper relative path behavior