Use semver parser instead of regex

This commit is contained in:
Matthias Beyer 2016-01-18 22:34:41 +01:00
parent b486960720
commit b0859c3e2f

View file

@ -138,7 +138,7 @@ fn has_main_section(t: &Table) -> bool {
}
fn has_imag_version_in_main_section(t: &Table) -> bool {
use regex::Regex;
use semver::Version;
match t.get("imag").unwrap() {
&Value::Table(ref sec) => {
@ -146,7 +146,7 @@ fn has_imag_version_in_main_section(t: &Table) -> bool {
.and_then(|v| {
match v {
&Value::String(ref s) => {
Some(Regex::new(r"^\d{1}\.\d{1}\.\d{1}(.*)").unwrap().is_match(&s[..]))
Some(Version::parse(&s[..]).is_ok())
},
_ => Some(false),
}