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:
Andras Bacsai
2026-03-24 08:03:08 +01:00
parent 0aee5a41ae
commit 988dd57cf4
5 changed files with 106 additions and 11 deletions
+10 -1
View File
@@ -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;
}
/**