mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Avoid panic for invalid, non-base index URLs (#4527)
## Summary See: https://github.com/astral-sh/uv/issues/4510
This commit is contained in:
parent
904957bf80
commit
a07e70d93a
2 changed files with 4 additions and 1 deletions
|
@ -137,6 +137,9 @@ pub enum ErrorKind {
|
||||||
#[error("Expected a file URL, but received: {0}")]
|
#[error("Expected a file URL, but received: {0}")]
|
||||||
NonFileUrl(Url),
|
NonFileUrl(Url),
|
||||||
|
|
||||||
|
#[error("Expected an index URL, but received non-base URL: {0}")]
|
||||||
|
CannotBeABase(Url),
|
||||||
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
DistInfo(#[from] install_wheel_rs::Error),
|
DistInfo(#[from] install_wheel_rs::Error),
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,7 @@ impl RegistryClient {
|
||||||
// Format the URL for PyPI.
|
// Format the URL for PyPI.
|
||||||
let mut url: Url = index.clone().into();
|
let mut url: Url = index.clone().into();
|
||||||
url.path_segments_mut()
|
url.path_segments_mut()
|
||||||
.unwrap()
|
.map_err(|()| ErrorKind::CannotBeABase(index.clone().into()))?
|
||||||
.pop_if_empty()
|
.pop_if_empty()
|
||||||
.push(package_name.as_ref())
|
.push(package_name.as_ref())
|
||||||
// The URL *must* end in a trailing slash for proper relative path behavior
|
// The URL *must* end in a trailing slash for proper relative path behavior
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue