fix: lowercase filename when checking for language_id

This commit is contained in:
panekj 2022-09-01 09:16:17 +02:00 committed by Jakub Panek
parent c7f4b7d82f
commit f951f6248d
1 changed files with 7 additions and 3 deletions

View File

@ -240,10 +240,14 @@ pub fn language_id_from_path(path: &Path) -> Option<&'static str> {
} }
} }
// Handle paths without extension // Handle paths without extension
#[allow(clippy::match_single_binding)]
None => match path.file_name()?.to_str()? { None => match path.file_name()?.to_str()? {
"dockerfile" => "dockerfile", // case-insensitive matching
"makefile" | "gnumakefile" => "makefile", filename => match filename.to_lowercase().as_str() {
_ => return None, "dockerfile" => "dockerfile",
"makefile" | "gnumakefile" => "makefile",
_ => return None,
},
}, },
}) })
} }