Skip to content
Snippets Groups Projects
Commit 6609e59a authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire: Committed by Reiter, Christoph
Browse files

Add getFileExtension and getBaseName (VPU/Apps/Signature#28)

parent 3e376843
No related branches found
No related tags found
No related merge requests found
......@@ -333,3 +333,29 @@ export async function getMimeTypeOfFile(file) {
fileReader.readAsArrayBuffer(file.slice(0, 4));
});
}
/**
* Get the basename of a filename
*
* @param str
* @returns {string}
*/
export const getBaseName = (str) => {
let base = String(str).substring(str.lastIndexOf('/') + 1);
if (base.lastIndexOf(".") !== -1) {
base = base.substring(0, base.lastIndexOf("."));
}
return base;
};
/**
* Get the file extension of a filename
*
* @param str
* @returns {string}
*/
export const getFileExtension = (str) => {
return str.split('.').pop();
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment