From 100fa8b3d1540d00154812003fd4c24acfaf5668 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Tue, 9 Jul 2024 09:37:55 +0300 Subject: [PATCH] melib/utils: fix edge case in ShellExpandTrait If there is no "/" prefix after stripping the argument prefix, the result was reverted. Signed-off-by: Manos Pitsidianakis --- melib/src/utils/shellexpand.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/melib/src/utils/shellexpand.rs b/melib/src/utils/shellexpand.rs index 55193599..4edd4ed8 100644 --- a/melib/src/utils/shellexpand.rs +++ b/melib/src/utils/shellexpand.rs @@ -348,7 +348,7 @@ pub mod impls { Self::from_bytes( self.as_bytes() .strip_prefix(prefix.as_bytes()) - .and_then(|s| s.strip_prefix(b"/")) + .and_then(|s| s.strip_prefix(b"/").or(Some(s))) .unwrap_or_else(|| { self.as_bytes() .strip_prefix(b"/")