mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
23 lines
690 B
TypeScript
23 lines
690 B
TypeScript
interface DatabaseConnectionFields {
|
|||
|
|
connectionString: string;
|
||
|
|
name: string;
|
||
|
|
password?: string;
|
||
|
|
username: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const jdbcConnectionString = ({ connectionString, name, password, username }: DatabaseConnectionFields) => {
|
||
|
|
const credentials = new URLSearchParams({ user: username });
|
||
|
|
if (password) {
|
||
|
|
credentials.set('password', password);
|
||
|
|
}
|
||
|
|
|
||
|
|
return `jdbc:mysql://${connectionString}/${name}?${credentials.toString()}`;
|
||
|
|
};
|
||
|
|
|
||
|
|
/** Strips the `s{serverId}_` prefix. */
|
||
|
|
export const serverDatabaseShortName = (name: string): string => {
|
||
|
|
const separator = name.indexOf('_');
|
||
|
|
|
||
|
|
return separator === -1 ? name : name.slice(separator + 1);
|
||
|
|
};
|