mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
fix: fixed/improved handling of app names in api
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { generatePassword } from "@dokploy/server/templates/utils";
|
||||
import { faker } from "@faker-js/faker";
|
||||
import { customAlphabet } from "nanoid";
|
||||
|
||||
@@ -13,3 +14,17 @@ export const generateAppName = (type: string) => {
|
||||
const nanoidPart = customNanoid();
|
||||
return `${type}-${randomFakerElement}-${nanoidPart}`;
|
||||
};
|
||||
|
||||
export const cleanAppName = (appName?: string) => {
|
||||
if (!appName) {
|
||||
return appName;
|
||||
}
|
||||
return appName.trim().replace(/ /g, "-");
|
||||
};
|
||||
|
||||
export const buildAppName = (type: string, baseAppName?: string) => {
|
||||
if (baseAppName) {
|
||||
return `${cleanAppName(baseAppName)}-${generatePassword(6)}`;
|
||||
}
|
||||
return generateAppName(type);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user