- 'file' util added
- getFileExtension method
This commit is contained in:
Chesterkxng
2025-12-10 16:43:04 +01:00
parent adbc389c5d
commit 82b56b4973

11
src/utils/file.ts Normal file
View File

@@ -0,0 +1,11 @@
/**
* Returns the file extension
*
* @param {string} filename - The filename
* @return {string} - the file extension
*/
export function getFileExtension(filename: string): string {
const lastDot = filename.lastIndexOf('.');
if (lastDot <= 0) return ''; // No extension
return filename.slice(lastDot + 1).toLowerCase();
}