mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-12-29 16:16:02 +00:00
Chore:
- 'file' util added - getFileExtension method
This commit is contained in:
11
src/utils/file.ts
Normal file
11
src/utils/file.ts
Normal 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();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user