Skip to content

Commit

Permalink
fix: Recognize version that start with v when leading inequality sign (
Browse files Browse the repository at this point in the history
  • Loading branch information
tolluset authored May 28, 2024
1 parent 42313ff commit a4f0a7d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/version-spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn clean_version_string<T: AsRef<str>>(value: T) -> String {
}

// Remove invalid space after <, <=, >, >=.
let version = regex::Regex::new(r"([><]=?)[ ]+([0-9])")
let version = regex::Regex::new(r"([><]=?)[ ]*v?([0-9])")
.unwrap()
.replace_all(&version, "$1$2");

Expand Down Expand Up @@ -95,6 +95,11 @@ mod tests {
assert_eq!(clean_version_string("<1.2.3"), "<1.2.3");
assert_eq!(clean_version_string("<= 1.2.3"), "<=1.2.3");

assert_eq!(clean_version_string(">= v1.2.3"), ">=1.2.3");
assert_eq!(clean_version_string("> v1.2.3"), ">1.2.3");
assert_eq!(clean_version_string("<v1.2.3"), "<1.2.3");
assert_eq!(clean_version_string("<= v1.2.3"), "<=1.2.3");

assert_eq!(clean_version_string("1.2, 3"), "1.2,3");
assert_eq!(clean_version_string("1,3, 4"), "1,3,4");
assert_eq!(clean_version_string("1 2"), "1,2");
Expand Down

0 comments on commit a4f0a7d

Please sign in to comment.