File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,10 +101,13 @@ var safeZoneRE = regexp.MustCompile(`[^a-z0-9-]+`)
101101
102102// Zone names have the same requirements as label values.
103103func SafeZoneName (input string ) string {
104- input = strings .ToLower (input ) // Rule 1: lowercase
105- safe := safeZoneRE .ReplaceAllString (input , "-" ) // Rule 1: only letters, numbers, and hyphen
106- safe = strings .Trim (safe , "-" ) // Rule 3, 4: trim hyphens from start and end
107- if len (safe ) == 0 || (safe [0 ] < 'a' || safe [0 ] > 'z' ) { // Rule 3: must start with a letter
104+ input = strings .ToLower (input ) // Rule 1: lowercase
105+ safe := safeZoneRE .ReplaceAllString (input , "-" ) // Rule 1: only letters, numbers, and hyphen
106+ safe = strings .Trim (safe , "-" ) // Rule 3, 4: trim hyphens from start and end
107+ if len (safe ) == 0 {
108+ safe = "zone"
109+ }
110+ if safe [0 ] < 'a' || safe [0 ] > 'z' { // Rule 3: must start with a letter
108111 safe = "zone-" + safe
109112 }
110113 return hashTrim (safe , 63 ) // Rule 2: max length 63
You can’t perform that action at this time.
0 commit comments