Fix double file extension on uploaded images

This commit is contained in:
valadaptive
2023-12-06 17:29:10 -05:00
parent 66da13b1bb
commit 9c850b0b0c
2 changed files with 15 additions and 3 deletions

View File

@ -298,6 +298,15 @@ function clientRelativePath(inputPath) {
return path.normalize(inputPath).split(path.sep).slice(1).join('/');
}
/**
* Strip the last file extension from a given file name. If there are multiple extensions, only the last is removed.
* @param {string} filename The file name to remove the extension from.
* @returns The file name, sans extension
*/
function removeFileExtension(filename) {
return filename.replace(/\.[^.]+$/, '');
}
module.exports = {
getConfig,
getConfigValue,
@ -313,4 +322,5 @@ module.exports = {
humanizedISO8601DateTime,
tryParse,
clientRelativePath,
removeFileExtension,
};