Skip to content

Commit

Permalink
Abort ignored filename suffix stripping early on unworkable filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Jul 9, 2021
1 parent dc8ab0b commit 21338ed
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,11 @@ impl HighlightingAssets {
.and_then(|x| x.to_str())
.unwrap_or_default(),
).or_else(|| {
let file_str = file_path.to_str().unwrap_or_default();
for suffix in IGNORED_SUFFIXES.iter() {
if let Some(stripped_filename) = file_str.strip_suffix(suffix) {
return self.get_extension_syntax(OsStr::new(stripped_filename));
if let Some(file_str) = file_path.to_str() {
for suffix in IGNORED_SUFFIXES.iter() {
if let Some(stripped_filename) = file_str.strip_suffix(suffix) {
return self.get_extension_syntax(OsStr::new(stripped_filename));
}
}
}
None
Expand Down

0 comments on commit 21338ed

Please sign in to comment.