@akadenia/helpers
Version:
Akadenia helpers
18 lines (17 loc) • 679 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkFileExtension = void 0;
/**
* Check if a file path has a valid extension
* @param filePath The file path to check
* @param validExtensions The valid extensions
* @returns true if the file path has a valid extension
* @example
* checkFileExtension("test.geojson", ["geojson", "json"]) // true
* checkFileExtension("test.txt", ["md"]) // false
*/
const checkFileExtension = (filePath, validExtensions) => {
const fileExtension = filePath.split(".").pop();
return !!fileExtension && validExtensions.includes(fileExtension);
};
exports.checkFileExtension = checkFileExtension;