Commit 94138414 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix app name generation: lowercase only, skip deleted records

CapRover only allows lowercase letters and single hyphens. The generator
now strips invalid chars, forces lowercase suffix, and ignores deleted
instances when checking for collisions.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent b4f4fd5c
......@@ -220,13 +220,18 @@ public function updateEnvVars(Instance $instance, array $vars): void
private function generateAppName(string $academyName): string
{
// CapRover only allows lowercase letters and single hyphens
$base = Str::slug($academyName);
$base = preg_replace('/[^a-z0-9\-]/', '', $base);
$base = trim(preg_replace('/-+/', '-', $base), '-');
$base = Str::limit($base, 30, '');
if (!Instance::where('app_name', $base)->exists()) {
if (!Instance::where('app_name', $base)->whereNot('status', 'deleted')->exists()) {
return $base;
}
return $base . '-' . Str::random(4);
// Suffix must also be lowercase only
$suffix = strtolower(Str::random(4));
return Str::limit($base, 25, '') . '-' . $suffix;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment