Skip to content

Commit

Permalink
Add @ separator (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle authored Nov 14, 2024
1 parent d7f922c commit 61db05a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->
## [Unreleased] - ReleaseDate
### Fixed
- [PR#96](https://github.com/EmbarkStudios/krates/pull/96) fixed an issue where package specs didn't allow the `@` separator, resolving [cargo-deny#717](https://github.com/EmbarkStudios/cargo-deny/issues/717).

## [0.17.3] - 2024-11-11
### Fixed
- [PR#94](https://github.com/EmbarkStudios/krates/pull/94) fixed an issue with canonical path mismatches (I presume on Windows). Thanks [@Tastaturtaste](http://github.com/Tastaturtaste)!
Expand Down
31 changes: 18 additions & 13 deletions src/pkgspec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl PkgSpec {
return false;
}

if let Some(ref vers) = self.version {
if let Some(vers) = &self.version {
if vers != &krate.version {
return false;
}
Expand Down Expand Up @@ -87,7 +87,7 @@ impl std::str::FromStr for PkgSpec {

match nv {
Some(nv) => {
match nv.find(':') {
match nv.find([':', '@']) {
Some(ind) => {
if ind == nv.len() - 1 {
return Err(Error::InvalidPkgSpec(
Expand Down Expand Up @@ -184,11 +184,13 @@ mod test {

#[test]
fn name_and_version() {
let spec: PkgSpec = "bitflags:1.0.4".parse().unwrap();
for spec in ["bitflags:1.0.4", "[email protected]"] {
let spec: PkgSpec = spec.parse().unwrap();

assert_eq!("bitflags", spec.name);
assert_eq!(Version::parse("1.0.4").unwrap(), spec.version.unwrap());
assert!(spec.url.is_none());
assert_eq!("bitflags", spec.name);
assert_eq!(Version::parse("1.0.4").unwrap(), spec.version.unwrap());
assert!(spec.url.is_none());
}
}

#[test]
Expand Down Expand Up @@ -225,13 +227,16 @@ mod test {

#[test]
fn url_and_name_and_version() {
let spec: PkgSpec = "https://github.com/rust-lang/cargo#crates-io:0.21.0"
.parse()
.unwrap();

assert_eq!("crates-io", spec.name);
assert_eq!(Version::parse("0.21.0").unwrap(), spec.version.unwrap());
assert_eq!("https://github.com/rust-lang/cargo", spec.url.unwrap());
for spec in [
"https://github.com/rust-lang/cargo#crates-io:0.21.0",
"https://github.com/rust-lang/cargo#[email protected]",
] {
let spec: PkgSpec = spec.parse().unwrap();

assert_eq!("crates-io", spec.name);
assert_eq!(Version::parse("0.21.0").unwrap(), spec.version.unwrap());
assert_eq!("https://github.com/rust-lang/cargo", spec.url.unwrap());
}
}

#[test]
Expand Down

0 comments on commit 61db05a

Please sign in to comment.