mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
fix: sparse URLs in TomlLockfileSourceId
This commit is contained in:
parent
d93be027f1
commit
00085c1aa7
@ -109,9 +109,13 @@ impl TomlLockfileSourceId {
|
||||
EncodableSourceIdError(EncodableSourceIdErrorKind::InvalidSource(source.clone()).into())
|
||||
})?;
|
||||
|
||||
let url = Url::parse(url).map_err(|msg| EncodableSourceIdErrorKind::InvalidUrl {
|
||||
url: url.to_string(),
|
||||
msg: msg.to_string(),
|
||||
// Sparse URLs store the kind prefix (sparse+) in the URL. Therefore, for sparse kinds, we
|
||||
// want to use the raw `source` instead of the splitted `url`.
|
||||
let url = Url::parse(if kind == "sparse" { &source } else { url }).map_err(|msg| {
|
||||
EncodableSourceIdErrorKind::InvalidUrl {
|
||||
url: url.to_string(),
|
||||
msg: msg.to_string(),
|
||||
}
|
||||
})?;
|
||||
|
||||
let kind = match kind {
|
||||
@ -347,7 +351,7 @@ mod tests {
|
||||
ok(
|
||||
"sparse+https://my-crates.io",
|
||||
SourceKind::SparseRegistry,
|
||||
"https://my-crates.io/",
|
||||
"sparse+https://my-crates.io",
|
||||
);
|
||||
ok(
|
||||
"registry+https://github.com/rust-lang/crates.io-index",
|
||||
|
Loading…
x
Reference in New Issue
Block a user