Skip to content

Commit f950b27

Browse files
committed
handle pkg ids that are raw registry urls
1 parent 4b34ce4 commit f950b27

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/crates/mod.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,24 @@ impl TryFrom<&'_ PackageId> for Crate {
114114
}
115115
}
116116
}
117+
["registry", url, ..] => {
118+
let Some((_registry, krate)) = url.split_once('#') else {
119+
bail!(
120+
"malformed pkgid format: {}\n maybe the representation has changed?",
121+
pkgid.repr
122+
);
123+
};
124+
let Some((crate_name, crate_version)) = krate.split_once('@') else {
125+
bail!(
126+
"malformed pkgid format: {}\n maybe the representation has changed?",
127+
pkgid.repr
128+
);
129+
};
130+
Ok(Crate::Registry(RegistryCrate {
131+
name: crate_name.to_string(),
132+
version: crate_version.to_string(),
133+
}))
134+
}
117135
_ => bail!(
118136
"malformed pkgid format: {}\n maybe the representation has changed?",
119137
pkgid.repr
@@ -252,7 +270,7 @@ mod tests {
252270
.to_string(),
253271
sha: None
254272
}),
255-
"registry+https://github.com/rust-lang/crates.io-index#cookie@0.15.0" => Crate::Registry(RegistryCrate {
273+
"registry+https://github.com/rust-lang/crates.io-index#cookie@0.15.0" => Crate::Registry(RegistryCrate {
256274
name: "cookie".to_string(),
257275
version: "0.15.0".to_string(),
258276
}),

0 commit comments

Comments
 (0)