MCPcopy
hub / github.com/github/github-mcp-server / ParseScopeHeader

Function ParseScopeHeader

pkg/scopes/fetcher.go:106–120  ·  view source on GitHub ↗

ParseScopeHeader parses the X-OAuth-Scopes header value into a list of scopes. The header contains comma-separated scope names. Returns an empty slice for empty or missing header.

(header string)

Source from the content-addressed store, hash-verified

104// The header contains comma-separated scope names.
105// Returns an empty slice for empty or missing header.
106func ParseScopeHeader(header string) []string {
107 if header == "" {
108 return []string{}
109 }
110
111 parts := strings.Split(header, ",")
112 scopes := make([]string, 0, len(parts))
113 for _, part := range parts {
114 scope := strings.TrimSpace(part)
115 if scope != "" {
116 scopes = append(scopes, scope)
117 }
118 }
119 return scopes
120}
121
122// FetchTokenScopes is a convenience function that creates a default fetcher
123// and fetches the token scopes.

Callers 2

FetchTokenScopesMethod · 0.85
TestParseScopeHeaderFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseScopeHeaderFunction · 0.68