Enhance convert_path_with_tilde_expansion to handle Windows (#4390)
This commit is contained in:
@@ -36,11 +36,25 @@ pub fn read_recipe_file<P: AsRef<Path>>(recipe_path: P) -> Result<RecipeFile> {
|
||||
|
||||
fn convert_path_with_tilde_expansion(path: &Path) -> PathBuf {
|
||||
if let Some(path_str) = path.to_str() {
|
||||
// Handle exact "~" (Windows only to avoid changing behavior on Unix)
|
||||
if cfg!(windows) && path_str == "~" {
|
||||
if let Some(home_dir) = dirs::home_dir() {
|
||||
return home_dir;
|
||||
}
|
||||
}
|
||||
// Handle Unix-style "~/..."
|
||||
if let Some(stripped) = path_str.strip_prefix("~/") {
|
||||
if let Some(home_dir) = dirs::home_dir() {
|
||||
return home_dir.join(stripped);
|
||||
}
|
||||
}
|
||||
// Handle Windows-style "~\\..." (Windows only)
|
||||
#[cfg(windows)]
|
||||
if let Some(stripped) = path_str.strip_prefix("~\\") {
|
||||
if let Some(home_dir) = dirs::home_dir() {
|
||||
return home_dir.join(stripped);
|
||||
}
|
||||
}
|
||||
}
|
||||
PathBuf::from(path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user