isValidName checks if the context-name is valid ("^[a-zA-Z0-9][a-zA-Z0-9_.+-]+$"). Names must start with an alphanumeric character (a-zA-Z0-9), followed by alphanumeric or separators ("_", ".", "+", "-").
(s string)
| 236 | // Names must start with an alphanumeric character (a-zA-Z0-9), followed by |
| 237 | // alphanumeric or separators ("_", ".", "+", "-"). |
| 238 | func isValidName(s string) bool { |
| 239 | if len(s) < 2 || !isAlphaNum(s[0]) { |
| 240 | return false |
| 241 | } |
| 242 | |
| 243 | for i := 1; i < len(s); i++ { |
| 244 | c := s[i] |
| 245 | if isAlphaNum(c) || c == '_' || c == '.' || c == '+' || c == '-' { |
| 246 | continue |
| 247 | } |
| 248 | return false |
| 249 | } |
| 250 | |
| 251 | return true |
| 252 | } |
| 253 | |
| 254 | func isAlphaNum(c byte) bool { |
| 255 | return (c >= 'a' && c <= 'z') || |
no test coverage detected
searching dependent graphs…