fix: path resolver in windows (#5209)

This commit is contained in:
Louis 2025-06-06 17:26:08 +07:00 committed by GitHub
parent 19bcce80fa
commit c444643294
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -43,7 +43,7 @@ pub fn join_path<R: Runtime>(
}
let path = resolve_path(app_handle, &args[0]);
let joined_path = path.join(args[1..].join("/"));
let joined_path = args[1..].iter().fold(path, |acc, part| acc.join(part));
Ok(joined_path.to_string_lossy().to_string())
}
@ -136,7 +136,10 @@ fn normalize_file_path(path: &str) -> String {
fn resolve_path<R: Runtime>(app_handle: tauri::AppHandle<R>, path: &str) -> PathBuf {
let path = if path.starts_with("file:/") || path.starts_with("file:\\") {
let normalized = normalize_file_path(path);
let relative_normalized = normalized.strip_prefix("/").unwrap_or(&normalized);
let relative_normalized = normalized
.trim_start_matches(std::path::MAIN_SEPARATOR)
.trim_start_matches('/')
.trim_start_matches('\\');
get_jan_data_folder_path(app_handle).join(relative_normalized)
} else {
PathBuf::from(path)