@@ -5,9 +5,8 @@ use std::path::{Component, Path, PathBuf};
5/// is available, otherwise returns the path unchanged.
5/// is available, otherwise returns the path unchanged.
6pub fn fold_home_dir(path: &Path) -> PathBuf {
6pub fn fold_home_dir(path: &Path) -> PathBuf {
7 if let Ok(home) = home_dir() {
7 if let Ok(home) = home_dir() {
8− if path.starts_with(&home) {
8+ if let Ok(stripped) = path.strip_prefix(&home) {
9− // it's ok to unwrap, the path starts with home dir
10− return PathBuf::from("~").join(path.strip_prefix(&home).unwrap());
9+ return PathBuf::from("~").join(stripped);