mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 11:35:45 +00:00
fix handling of unknown extensions
This commit is contained in:
parent
bef3e9e2fa
commit
2238a20f0f
@ -113,11 +113,12 @@ fn to_extension(ext: &[u8]) -> Option<Extension> {
|
||||
))
|
||||
}
|
||||
|
||||
fn split_extension<'a>(name: &mut &'a [u8]) -> Option<&'a [u8]> {
|
||||
fn split_extension(name: &mut &[u8]) -> Option<Extension> {
|
||||
let (new_name, ext) = name.rsplit_once_str(b".")?;
|
||||
if matches!(new_name, b"" | b"." | b"..") {
|
||||
return None;
|
||||
}
|
||||
let ext = to_extension(ext)?;
|
||||
*name = new_name;
|
||||
Some(ext)
|
||||
}
|
||||
@ -149,7 +150,7 @@ pub fn separate_known_extensions_from_name(path: &Path) -> (&Path, Vec<Extension
|
||||
};
|
||||
|
||||
// While there is known extensions at the tail, grab them
|
||||
while let Some(extension) = split_extension(&mut name).and_then(to_extension) {
|
||||
while let Some(extension) = split_extension(&mut name) {
|
||||
extensions.insert(0, extension);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user