15 lines
385 B
TypeScript
15 lines
385 B
TypeScript
![]() |
type Param = {
|
||
|
str: string;
|
||
|
userId: string | number;
|
||
|
};
|
||
|
export default function replaceDatasquirelDbName({
|
||
|
str,
|
||
|
userId,
|
||
|
}: Param): string {
|
||
|
const dbNamePrefix = process.env.DSQL_USER_DB_PREFIX;
|
||
|
const userNameRegex = new RegExp(`${dbNamePrefix}\\d+_`, "g");
|
||
|
const newPrefix = `${dbNamePrefix}${userId}_`;
|
||
|
|
||
|
return str.replace(userNameRegex, newPrefix);
|
||
|
}
|