This commit is contained in:
Benjamin Toby
2025-01-14 11:33:30 +01:00
parent d55fe64d47
commit 03d4fdc270
12 changed files with 79 additions and 52 deletions
+18
View File
@@ -0,0 +1,18 @@
type Param = {
dbName: string;
userId?: string | number;
};
/**
* # Grab Database Full Name
*/
export default function grabDbFullName({ dbName, userId }: Param): string {
const sanitizedName = dbName.replace(/[^a-z0-9\_]/g, "");
const cleanedDbName = sanitizedName.replace(/datasquirel_user_\d+_/, "");
if (!userId) return cleanedDbName;
const dbNamePrefix = `datasquirel_user_${userId}_`;
return dbNamePrefix + cleanedDbName;
}