From 5d679ca8cdc2e79b6e6db7dd7ca2fc099da5a709 Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Mon, 17 Jul 2023 19:42:28 +0200 Subject: feat: Implement `to_string` for `ParsedThunderstoreModString` (#420) Allows printing `ParsedThunderstoreModString` in the Thunderstore mod string format --- src-tauri/src/mod_management/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs index a2aca85a..6c45a23b 100644 --- a/src-tauri/src/mod_management/mod.rs +++ b/src-tauri/src/mod_management/mod.rs @@ -36,6 +36,12 @@ impl std::str::FromStr for ParsedThunderstoreModString { } } +impl ToString for ParsedThunderstoreModString { + fn to_string(&self) -> String { + format!("{}-{}-{}", self.author_name, self.mod_name, self.version) + } +} + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ThunderstoreManifest { name: String, -- cgit v1.2.3 From 605d7a137e94f5b86e45182c3709128ef57237ae Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Mon, 17 Jul 2023 19:42:45 +0200 Subject: fix: Add regex check for parsing TS mod string (#421) Otherwise we accept improper formatted Thunderstore mod strings like `AUTHOR-MOD-VERSION-RANDOM_STUFF` --- src-tauri/src/mod_management/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs index 6c45a23b..afcead16 100644 --- a/src-tauri/src/mod_management/mod.rs +++ b/src-tauri/src/mod_management/mod.rs @@ -22,6 +22,12 @@ impl std::str::FromStr for ParsedThunderstoreModString { type Err = &'static str; // todo use an better error management fn from_str(s: &str) -> Result { + // Check whether Thunderstore string passse reges + let re = regex::Regex::new(r"^[a-zA-Z0-9_]+-[a-zA-Z0-9_]+-\d+\.\d+\.\d++$").unwrap(); + if !re.is_match(s) { + return Err("Incorrect format"); + } + let mut parts = s.split('-'); let author_name = parts.next().ok_or("None value on author_name")?.to_string(); -- cgit v1.2.3 From a5681f3511ef1b62d4f10741c5aea5cb511c97d0 Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Mon, 17 Jul 2023 19:45:44 +0200 Subject: chore: Bump FlightCore version to 1.22.1 --- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 38994e27..0756d3b5 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -76,7 +76,7 @@ checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" [[package]] name = "app" -version = "1.22.0" +version = "1.22.1" dependencies = [ "anyhow", "async-recursion", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index ed24d34e..c11e658d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "app" -version = "1.22.0" +version = "1.22.1" description = "A Tauri App" authors = ["you"] license = "" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 81a43c1a..41157bda 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "FlightCore", - "version": "1.22.0" + "version": "1.22.1" }, "tauri": { "allowlist": { -- cgit v1.2.3