diff --git a/src/atom/parsers.rs b/src/atom/parsers.rs index 8026dfe..16e8fb1 100644 --- a/src/atom/parsers.rs +++ b/src/atom/parsers.rs @@ -28,7 +28,10 @@ pub fn version_operator<'a>() -> impl Parser<&'a str, Output = VersionOperator> } pub fn version_number<'a>() -> impl Parser<&'a str, Output = VersionNumber> { - numeric1().map(|output: &str| VersionNumber(output.to_string())) + numeric1() + .followed_by(opt(tag("*"))) + .recognize() + .map(|output: &str| VersionNumber(output.to_string())) } pub fn version_suffix_kind<'a>() -> impl Parser<&'a str, Output = VersionSuffixKind> { @@ -218,7 +221,15 @@ pub fn atom<'a>() -> impl Parser<&'a str, Output = Atom> { }, ) .verify_output(|atom| match (&atom.version_operator, &atom.version) { - (Some(_), Some(_)) => true, + (Some(VersionOperator::Eq), Some(_)) => true, + (Some(_), Some(version)) + if !version + .numbers() + .iter() + .any(|number| number.get().contains("*")) => + { + true + } (None, None) => true, _ => false, }) @@ -323,4 +334,18 @@ mod test { atom().check_finished(it).unwrap(); } + + #[test] + fn test_atom_with_star_in_version() { + let it = InputIter::new("=foo/bar-1.2*"); + + atom().check_finished(it).unwrap(); + } + + #[test] + fn test_atom_with_star_in_version_without_eq_version_operator() { + let it = InputIter::new(">=foo/bar-1.2*"); + + assert!(atom().check_finished(it).is_err()); + } }