MCPcopy Index your code
hub / github.com/FiloSottile/age / ParseRecipient

Function ParseRecipient

plugin/encode.go:57–70  ·  view source on GitHub ↗

ParseRecipient decodes a plugin recipient string. It returns the plugin name in lowercase and the encoded data.

(s string)

Source from the content-addressed store, hash-verified

55// ParseRecipient decodes a plugin recipient string. It returns the plugin name
56// in lowercase and the encoded data.
57func ParseRecipient(s string) (name string, data []byte, err error) {
58 hrp, data, err := bech32.Decode(s)
59 if err != nil {
60 return "", nil, fmt.Errorf("invalid recipient encoding: %v", err)
61 }
62 if !strings.HasPrefix(hrp, "age1") {
63 return "", nil, fmt.Errorf("not a plugin recipient: %v", err)
64 }
65 name = strings.TrimPrefix(hrp, "age1")
66 if !validPluginName(name) {
67 return "", nil, fmt.Errorf("invalid plugin name: %q", name)
68 }
69 return name, data, nil
70}
71
72func validPluginName(name string) bool {
73 if name == "" {

Callers 3

ParseRecipientFunction · 0.92
RecipientV1Method · 0.70
NewRecipientFunction · 0.70

Calls 2

DecodeFunction · 0.92
validPluginNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…