diff options
| author | 2026-01-14 15:55:55 +0800 | |
|---|---|---|
| committer | 2026-01-14 15:55:55 +0800 | |
| commit | 2cd4748417b77731096e9acc9b9f78b671a2a3cc (patch) | |
| tree | 058deda0e86ff12a16d9851fe76bcb38239acf26 | |
| parent | 30036f1e0eda71242a5b0f6823803fd84ca075af (diff) | |
| parent | 4843a4fc5e4f97790aba1fa5cc3b4ad5ac55c220 (diff) | |
| download | DropOut-2cd4748417b77731096e9acc9b9f78b671a2a3cc.tar.gz DropOut-2cd4748417b77731096e9acc9b9f78b671a2a3cc.zip | |
Merge pull request #24 from HsiangNianian/copilot/sub-pr-23
| -rw-r--r-- | src-tauri/src/main.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index c2fd098..a24510e 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -40,6 +40,27 @@ impl MsRefreshTokenState { } } +/// Check if a string contains unresolved placeholders in the form ${...} +/// +/// After the replacement phase, if a string still contains ${...}, it means +/// that placeholder variable was not found in the replacements map and is +/// therefore unresolved. We should skip adding such arguments to avoid +/// passing malformed arguments to the game launcher. +fn has_unresolved_placeholder(s: &str) -> bool { + // Look for the opening sequence + if let Some(start_pos) = s.find("${") { + // Check if there's a closing brace after the opening sequence + if s[start_pos + 2..].find('}').is_some() { + // Found a complete ${...} pattern - this is an unresolved placeholder + return true; + } + // Found ${ but no closing } - also treat as unresolved/malformed + return true; + } + // No ${ found - the string is fully resolved + false +} + #[tauri::command] async fn start_game( window: Window, @@ -450,7 +471,7 @@ async fn start_game( arg = arg.replace(key, replacement); } // Skip arguments with unresolved placeholders - if !arg.contains("${") { + if !has_unresolved_placeholder(&arg) { args.push(arg); } } else if let Some(arr) = val.as_array() { @@ -461,7 +482,7 @@ async fn start_game( arg = arg.replace(key, replacement); } // Skip arguments with unresolved placeholders - if !arg.contains("${") { + if !has_unresolved_placeholder(&arg) { args.push(arg); } } |