Merge pull request #1112 from panekj/fix/lowercase-filename

fix: lowercase filename when checking for language_id
This commit is contained in:
Dongdong Zhou 2022-09-10 12:49:03 +01:00 committed by GitHub
commit 9bff49dd68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
#[allow(clippy::match_single_binding)]
None => match path.file_name()?.to_str()? {
"dockerfile" => "dockerfile",
"makefile" | "gnumakefile" => "makefile",
_ => return None,
// case-insensitive matching
filename => match filename.to_lowercase().as_str() {
"dockerfile" => "dockerfile",
"makefile" | "gnumakefile" => "makefile",
_ => return None,
},
},
})
}