'use strict';

/**
 * Extracts the file extension from a filename.
 *
 * Returns the lowercased extension without the dot,
 * or an empty string if the filename has no extension.
 *
 * @param filename - the filename to extract the extension from
 */
function getFileExtension(filename) {
    if (!filename) {
        return '';
    }
    const lastDot = filename.lastIndexOf('.');
    if (lastDot < 1) {
        return '';
    }
    return filename.slice(lastDot + 1).toLowerCase();
}

exports.getFileExtension = getFileExtension;
