From 97c6a4c4efd99bcdd8c9988a74ff072c1350e59a Mon Sep 17 00:00:00 2001 From: James Collins Date: Mon, 24 Jul 2023 12:51:34 +1000 Subject: [PATCH] cleanup --- resources/js/helpers/utils.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/resources/js/helpers/utils.ts b/resources/js/helpers/utils.ts index b3f28bc..85fbb11 100644 --- a/resources/js/helpers/utils.ts +++ b/resources/js/helpers/utils.ts @@ -119,15 +119,20 @@ export const userHasPermission = (permission: string): boolean => { */ export const convertFileNameToTitle = (fileName: string): string => { // Remove file extension - const fileNameWithoutExtension = fileName.replace(/\.[^/.]+$/, ""); + fileName = fileName.replace(/\.[^/.]+$/, ""); - // Replace dash and underscore with space - const fileNameWithSpaces = fileNameWithoutExtension.replace(/[-_]/g, " "); + // Replace underscores with space + fileName = fileName.replace(/_/g, " "); + + // Replace dashes that are not surrounded by spaces with space + fileName = fileName.replace(/(?