mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-06 02:23:03 +00:00
feat(validation): make hostname validation case-insensitive and expand allowed characters
- Normalize hostnames to lowercase for RFC 1123 compliance while accepting uppercase input - Expand NAME_PATTERN to allow parentheses, hash, comma, colon, and plus characters - Add fallback to random name generation when application name doesn't meet minimum requirements - Add comprehensive test coverage for validation patterns and edge cases
This commit is contained in:
@@ -341,7 +341,16 @@ function generate_application_name(string $git_repository, string $git_branch, ?
|
||||
|
||||
$repo_name = str_contains($git_repository, '/') ? last(explode('/', $git_repository)) : $git_repository;
|
||||
|
||||
return Str::kebab("$repo_name:$git_branch-$cuid");
|
||||
$name = Str::kebab("$repo_name:$git_branch-$cuid");
|
||||
|
||||
// Strip characters not allowed by NAME_PATTERN
|
||||
$name = preg_replace('/[^\p{L}\p{M}\p{N}\s\-_.@\/&()#,:+]+/u', '', $name);
|
||||
|
||||
if (empty($name) || mb_strlen($name) < 3) {
|
||||
return generate_random_name($cuid);
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user