add method to remove extension from str

This commit is contained in:
Mylloon 2022-07-22 00:04:19 +02:00
parent 0cfea23150
commit f446913cd5
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -18,3 +18,15 @@ export const getFilename = (path: string) => {
return path_list[path_list.length - 1].split('.')[0];
};
/**
* Remove extension from a filename
* @param filename string of the filename with an extension
* @returns string of the filename without an extension
*/
export const removeExtension = (filename: string) => {
const array = filename.split('.');
array.pop();
return array.join('.');
};