File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
crates/cargo-util-schemas/src Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -109,9 +109,13 @@ impl TomlLockfileSourceId {
109
109
EncodableSourceIdError ( EncodableSourceIdErrorKind :: InvalidSource ( source. clone ( ) ) . into ( ) )
110
110
} ) ?;
111
111
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
+ }
115
119
} ) ?;
116
120
117
121
let kind = match kind {
@@ -347,7 +351,7 @@ mod tests {
347
351
ok (
348
352
"sparse+https://my-crates.io" ,
349
353
SourceKind :: SparseRegistry ,
350
- "https://my-crates.io/ " ,
354
+ "sparse+ https://my-crates.io" ,
351
355
) ;
352
356
ok (
353
357
"registry+https://github.com/rust-lang/crates.io-index" ,
You can’t perform that action at this time.
0 commit comments