From 8e72ae90c1ef56e50191cfa1a8db30beb68065f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Sun, 17 Sep 2023 01:29:44 +0800 Subject: [PATCH] fix: check relative path on `expand_path` (#165) --- core/src/files/sorter.rs | 2 +- shared/src/fns.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/files/sorter.rs b/core/src/files/sorter.rs index 5149a9ac..386d1bf8 100644 --- a/core/src/files/sorter.rs +++ b/core/src/files/sorter.rs @@ -1,4 +1,4 @@ -use std::{cmp::Ordering, collections::BTreeMap, mem, ops::Deref}; +use std::{cmp::Ordering, collections::BTreeMap, mem}; use config::{manager::SortBy, MANAGER}; use shared::Url; diff --git a/shared/src/fns.rs b/shared/src/fns.rs index 63b3cf96..5b915a98 100644 --- a/shared/src/fns.rs +++ b/shared/src/fns.rs @@ -11,7 +11,10 @@ pub fn expand_path(p: impl AsRef) -> PathBuf { return PathBuf::from_iter([&home, p.as_os_str()]); } } - p.to_path_buf() + if p.is_absolute() { + return p.to_path_buf(); + } + env::current_dir().map_or_else(|_| p.to_path_buf(), |c| c.join(p)) } #[inline]