From b0c3398689ec16d8393b5bec52114c3698dcd324 Mon Sep 17 00:00:00 2001 From: ayntee Date: Mon, 29 Mar 2021 21:07:36 +0400 Subject: [PATCH] fix(util/utils): remove ID handling from case manipulation functions --- src/util/utils.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/util/utils.ts b/src/util/utils.ts index d2dad7ecd..6dc5acce0 100644 --- a/src/util/utils.ts +++ b/src/util/utils.ts @@ -53,19 +53,14 @@ export const formatImageURL = ( }; function camelToSnakeCase(text: string) { - return text.replace(/Id|[A-Z]/g, ($1) => { - if ($1 === "Id") return "_id"; - - return `_${$1.toLowerCase()}`; - }); + return text.replace(/Id|[A-Z]/g, ($1) => `_${$1.toLowerCase()}`); } function snakeToCamelCase(text: string) { - return text.replace(/_id|([-_][a-z])/ig, ($1) => { - if ($1 === "_id") return "Id"; - - return $1.toUpperCase().replace("_", ""); - }); + return text.replace( + /_id|([-_][a-z])/ig, + ($1) => $1.toUpperCase().replace("_", ""), + ); } function isObject(obj: unknown) {