dsql-admin/dsql-app/package-shared/utils/grab-db-full-name.ts
Benjamin Toby 81cf010cb5 Updates
2025-01-14 16:27:08 +01:00

19 lines
463 B
TypeScript

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;
}