diff --git a/yazi-actor/src/cmp/trigger.rs b/yazi-actor/src/cmp/trigger.rs index 038aa97e..532774c7 100644 --- a/yazi-actor/src/cmp/trigger.rs +++ b/yazi-actor/src/cmp/trigger.rs @@ -75,7 +75,7 @@ impl Trigger { } #[cfg(windows)] - const SEP: [char; 2] = ['/', '\\']; + const SEP: &[char] = &['/', '\\']; #[cfg(not(windows))] const SEP: char = std::path::MAIN_SEPARATOR; diff --git a/yazi-fs/src/path.rs b/yazi-fs/src/path.rs index 9538b910..ac8290d7 100644 --- a/yazi-fs/src/path.rs +++ b/yazi-fs/src/path.rs @@ -75,17 +75,20 @@ fn _expand_url(url: &Url) -> Cow<'_, Url> { .and_then(env::var_os) .map_or_else(|| caps.get(0).unwrap().as_bytes().to_owned(), |s| s.into_encoded_bytes()) }); - if matches!(b, Cow::Borrowed(_)) { - return url.into(); - } - let p = unsafe { PathBuf::from(OsString::from_encoded_bytes_unchecked(b.into_owned())) }; - if let Some(rest) = p.strip_prefix("~").ok().filter(|_| local) { + let path: Cow<_> = unsafe { + match b { + Cow::Borrowed(b) => Path::new(OsStr::from_encoded_bytes_unchecked(b)).into(), + Cow::Owned(b) => PathBuf::from(OsString::from_encoded_bytes_unchecked(b)).into(), + } + }; + + if let Some(rest) = path.strip_prefix("~").ok().filter(|_| local) { url.with(clean_path(&dirs::home_dir().unwrap_or_default().join(rest))).into() - } else if p.is_absolute() { - url.with(clean_path(&p)).into() + } else if path.is_absolute() { + url.with(clean_path(&path)).into() } else { - clean_url(CWD.load().join(p)) + clean_url(CWD.load().join(path)) } } diff --git a/yazi-shared/src/osstr.rs b/yazi-shared/src/osstr.rs index 3d1ac500..9e5a6fd2 100644 --- a/yazi-shared/src/osstr.rs +++ b/yazi-shared/src/osstr.rs @@ -90,6 +90,6 @@ impl Pattern for char { fn predicate(&self, byte: u8) -> bool { *self == byte as char } } -impl Pattern for [char] { +impl Pattern for &[char] { fn predicate(&self, byte: u8) -> bool { self.contains(&(byte as char)) } }