From f446913cd5a7fe89d348274fe22e583bd23ee72c Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 22 Jul 2022 00:04:19 +0200 Subject: [PATCH] add method to remove extension from str --- src/utils/misc.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/utils/misc.ts b/src/utils/misc.ts index 240f236..ef4bbee 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -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('.'); +};