Allow dashes and underscores in custom index names (#8339)

Previously, `uv add --index` command threw an error when the index name
included characters like hyphens or underscores.

Closes #8315
This commit is contained in:
Vini Brasil 2024-10-18 14:24:16 -03:00 committed by GitHub
parent c162078050
commit 69d5e084d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -158,7 +158,10 @@ impl FromStr for Index {
return Err(IndexSourceError::EmptyName);
}
if name.chars().all(char::is_alphanumeric) {
if name
.chars()
.all(|c| c.is_alphanumeric() || c == '-' || c == '_')
{
let url = IndexUrl::from_str(url)?;
return Ok(Self {
name: Some(name.to_string()),