mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
fix: avoid expanding paths for non-regular URLs
This commit is contained in:
parent
f3e45d4a47
commit
27255b22de
4 changed files with 14 additions and 13 deletions
|
|
@ -19,11 +19,11 @@ pub struct Boot {
|
|||
|
||||
impl Boot {
|
||||
fn parse_entry(entry: Option<PathBuf>) -> (PathBuf, Option<OsString>) {
|
||||
let Some(entry) = entry else {
|
||||
return (env::current_dir().unwrap(), None);
|
||||
let entry = match entry {
|
||||
Some(p) => expand_path(p),
|
||||
None => return (env::current_dir().unwrap(), None),
|
||||
};
|
||||
|
||||
let entry = expand_path(entry);
|
||||
let parent = entry.parent();
|
||||
if parent.is_none() || entry.is_dir() {
|
||||
return (entry, None);
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@ pub struct Opt {
|
|||
|
||||
impl From<&Exec> for Opt {
|
||||
fn from(e: &Exec) -> Self {
|
||||
Self {
|
||||
target: Url::from(expand_path(e.args.first().map(|s| s.as_str()).unwrap_or(""))),
|
||||
interactive: e.named.contains_key("interactive"),
|
||||
let mut target = Url::from(e.args.first().map(|s| s.as_str()).unwrap_or(""));
|
||||
if target.is_regular() {
|
||||
target.set_path(expand_path(&target))
|
||||
}
|
||||
|
||||
Self { target, interactive: e.named.contains_key("interactive") }
|
||||
}
|
||||
}
|
||||
impl From<Url> for Opt {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,12 @@ pub struct Opt {
|
|||
|
||||
impl From<&Exec> for Opt {
|
||||
fn from(e: &Exec) -> Self {
|
||||
Self { target: Url::from(expand_path(e.args.first().map(|s| s.as_str()).unwrap_or(""))) }
|
||||
let mut target = Url::from(e.args.first().map(|s| s.as_str()).unwrap_or(""));
|
||||
if target.is_regular() {
|
||||
target.set_path(expand_path(&target))
|
||||
}
|
||||
|
||||
Self { target }
|
||||
}
|
||||
}
|
||||
impl From<Url> for Opt {
|
||||
|
|
|
|||
|
|
@ -38,12 +38,6 @@ fn _expand_path(p: &Path) -> PathBuf {
|
|||
#[inline]
|
||||
pub fn expand_path(p: impl AsRef<Path>) -> PathBuf { _expand_path(p.as_ref()) }
|
||||
|
||||
#[inline]
|
||||
pub fn expand_url(mut u: Url) -> Url {
|
||||
u.set_path(_expand_path(&u));
|
||||
u
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn ends_with_slash(p: &Path) -> bool {
|
||||
// TODO: uncomment this when Rust 1.74 is released
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue