diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2023-01-22 18:46:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-22 18:46:47 +0100 |
commit | 2a9136fe520e5298d65603fc8804a7176b4719db (patch) | |
tree | c11ccb7f4f8dcd92884fc6e02ad1b2613a1a318d /src-tauri | |
parent | 70c3a381018e7aca75f37086ba4702688ba5b28c (diff) | |
download | FlightCore-2a9136fe520e5298d65603fc8804a7176b4719db.tar.gz FlightCore-2a9136fe520e5298d65603fc8804a7176b4719db.zip |
fix: Properly parse mod string (#141)
Diffstat (limited to 'src-tauri')
-rw-r--r-- | src-tauri/src/mod_management/mod.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs index 008f72f0..e45fa3c1 100644 --- a/src-tauri/src/mod_management/mod.rs +++ b/src-tauri/src/mod_management/mod.rs @@ -284,8 +284,19 @@ async fn get_ns_mod_download_url(thunderstore_mod_string: String) -> Result<Stri // TODO: This will crash the thread if not internet connection exist. `match` should be used instead let index = thermite::api::get_package_index().await.unwrap().to_vec(); - // String replace works but more care should be taken in the future - let ts_mod_string_url = thunderstore_mod_string.replace("-", "/"); + // Parse mod string + let parsed_ts_mod_string: ParsedThunderstoreModString = match thunderstore_mod_string.parse() { + Ok(res) => res, + Err(_) => return Err("Failed to parse mod string".to_string()), + }; + + // Encode as URL + let ts_mod_string_url = format!( + "{}/{}/{}", + parsed_ts_mod_string.author_name, + parsed_ts_mod_string.mod_name, + parsed_ts_mod_string.version.unwrap() + ); for ns_mod in index { // Iterate over all versions of a given mod |