diff --git a/Cargo.lock b/Cargo.lock index 5bc12be..9babfbc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -1716,6 +1716,7 @@ dependencies = [ "once_cell", "path-clean", "pathdiff", + "semver 1.0.23", "tokio", ] diff --git a/crates/lune-utils/Cargo.toml b/crates/lune-utils/Cargo.toml index 09459dd..138f680 100644 --- a/crates/lune-utils/Cargo.toml +++ b/crates/lune-utils/Cargo.toml @@ -22,3 +22,4 @@ dunce = "1.0" once_cell = "1.17" path-clean = "1.0" pathdiff = "0.2" +semver = "1.0" diff --git a/crates/lune-utils/src/version_string.rs b/crates/lune-utils/src/version_string.rs index 6c4bbcf..29f1d87 100644 --- a/crates/lune-utils/src/version_string.rs +++ b/crates/lune-utils/src/version_string.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use mlua::prelude::*; use once_cell::sync::Lazy; +use semver::Version; static LUAU_VERSION: Lazy> = Lazy::new(create_luau_version_string); @@ -20,12 +21,10 @@ pub fn get_version_string(lune_version: impl AsRef) -> String { let lune_version = lune_version.as_ref(); assert!(!lune_version.is_empty(), "Lune version string is empty"); - assert!( - lune_version.chars().all(is_valid_version_char), - "Lune version string contains invalid characters" - ); - - format!("Lune {lune_version}+{}", *LUAU_VERSION) + match Version::parse(lune_version) { + Ok(semver) => format!("Lune {semver}+{}", *LUAU_VERSION), + Err(e) => panic!("Lune version string is not valid semver: {e}"), + } } fn create_luau_version_string() -> Arc {