数通智联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
616 B

2 years ago
"use strict";
function getFileNameAndExtension(fullFileName) {
const lastDot = fullFileName.lastIndexOf('.'); // these count as no extension: "no-dot", "trailing-dot."
if (lastDot === -1 || lastDot === fullFileName.length - 1) {
return {
name: fullFileName,
extension: undefined
};
}
return {
name: fullFileName.slice(0, lastDot),
extension: fullFileName.slice(lastDot + 1)
};
}
/**
* Takes a full filename string and returns an object {name, extension}
*
* @param {string} fullFileName
* @returns {object} {name, extension}
*/
module.exports = getFileNameAndExtension;