MCPcopy Create free account
hub / github.com/github/gh-aw / isValidGitHubNameWithMaxLength

Function isValidGitHubNameWithMaxLength

pkg/parser/github_urls.go:360–375  ·  view source on GitHub ↗
(s string, maxLength int)

Source from the content-addressed store, hash-verified

358)
359
360func isValidGitHubNameWithMaxLength(s string, maxLength int) bool {
361 // GitHub identifiers can contain alphanumeric characters, hyphens, and underscores.
362 // They cannot start or end with a hyphen.
363 if s == "" || len(s) > maxLength {
364 return false
365 }
366 if s[0] == '-' || s[len(s)-1] == '-' {
367 return false
368 }
369 for _, ch := range s {
370 if (ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z') && (ch < '0' || ch > '9') && ch != '-' && ch != '_' {
371 return false
372 }
373 }
374 return true
375}
376
377// IsValidGitHubIdentifier checks if a string is a valid GitHub user or organization identifier.
378func IsValidGitHubIdentifier(s string) bool {

Callers 2

IsValidGitHubIdentifierFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected