UNPKG

@kitmi/utils

Version:

A JavaScript utility library for both server and browser

12 lines (10 loc) 358 B
/** * Split the base and extension (including the ".") of a file path. * @param {*} filePath * @returns (array) [base, ext] */ const splitBaseAndExt = (filePath) => { const pos = filePath.lastIndexOf('.'); return [pos === -1 ? filePath : filePath.substring(0, pos), pos === -1 ? '' : filePath.substring(pos)]; }; export default splitBaseAndExt;