Skip to content

Commit

Permalink
if no lang was found return original
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabwhy committed Mar 1, 2024
1 parent cf3f5df commit afb5bfb
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,19 @@ const LANG_STRS: [&str; 11] = [

fn strip_lang(path: &PathBuf) -> Option<PathBuf> {
let file_name = path.file_name()?.to_str()?.to_string();
let stripped_name = PathBuf::from(LANG_STRS.iter().find_map(|lang| {
if file_name.starts_with(lang) {
Some(file_name.replacen(lang, "", 1))
} else {
None
}
})?);
let stripped_name = PathBuf::from(
LANG_STRS
.iter()
.find_map(|lang| {
if file_name.starts_with(lang) {
Some(file_name.replacen(lang, "", 1))
} else {
None
}
})
.or(Some(file_name))
.unwrap(),
);
Some(path.parent()?.join(stripped_name))
}

Expand Down

0 comments on commit afb5bfb

Please sign in to comment.