Skip to content

Commit 4496834

Browse files
committed
fix: sparse URLs in TomlLockfileSourceId
1 parent ee515e6 commit 4496834

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

crates/cargo-util-schemas/src/lockfile.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,13 @@ impl TomlLockfileSourceId {
109109
EncodableSourceIdError(EncodableSourceIdErrorKind::InvalidSource(source.clone()).into())
110110
})?;
111111

112-
let url = Url::parse(url).map_err(|msg| EncodableSourceIdErrorKind::InvalidUrl {
113-
url: url.to_string(),
114-
msg: msg.to_string(),
112+
// Sparse URLs store the kind prefix (sparse+) in the URL. Therefore, for sparse kinds, we
113+
// want to use the raw `source` instead of the splitted `url`.
114+
let url = Url::parse(if kind == "sparse" { &source } else { url }).map_err(|msg| {
115+
EncodableSourceIdErrorKind::InvalidUrl {
116+
url: url.to_string(),
117+
msg: msg.to_string(),
118+
}
115119
})?;
116120

117121
let kind = match kind {

0 commit comments

Comments
 (0)