diff --git a/src/utils/file.ts b/src/utils/file.ts new file mode 100644 index 0000000..a3200ac --- /dev/null +++ b/src/utils/file.ts @@ -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(); +}