MCPcopy Create free account
hub / github.com/rilldata/rill / MatchByPrefix

Function MatchByPrefix

admin/pkg/authtoken/authtoken.go:154–165  ·  view source on GitHub ↗

MatchByPrefix attempts to match a decoded token by its prefix.

(input string, tokens []*Token)

Source from the content-addressed store, hash-verified

152
153// MatchByPrefix attempts to match a decoded token by its prefix.
154func MatchByPrefix(input string, tokens []*Token) []*Token {
155 if len(input) < 10 || !strings.HasPrefix(input, Prefix+"_") {
156 return nil
157 }
158 var matches []*Token
159 for _, t := range tokens {
160 if strings.HasPrefix(t.Prefix(), input) {
161 matches = append(matches, t)
162 }
163 }
164 return matches
165}
166
167// marshalBase62 marshals a byte slice to a string of [0-9A-Za-z] characters.
168func marshalBase62(val []byte) string {

Callers 2

TestMatchByPrefixFunction · 0.85

Calls 1

PrefixMethod · 0.80

Tested by 1

TestMatchByPrefixFunction · 0.68