MCPcopy Create free account
hub / github.com/easyp-tech/server / parseModuleRefByID

Function parseModuleRefByID

internal/connect/commits_helpers.go:258–294  ·  view source on GitHub ↗
(msg []byte, moduleLookup map[string]string)

Source from the content-addressed store, hash-verified

256}
257
258func parseModuleRefByID(msg []byte, moduleLookup map[string]string) *struct {
259 owner string
260 module string
261} {
262 for len(msg) > 0 {
263 num, typ, n := protowire.ConsumeTag(msg)
264 if n < 0 {
265 return nil
266 }
267 msg = msg[n:]
268 if num == 1 && typ == protowire.BytesType {
269 v, mLen := protowire.ConsumeBytes(msg)
270 msg = msg[mLen:]
271 id := string(v)
272 if key, ok := moduleLookup[id]; ok {
273 parts := strings.SplitN(key, "/", 2)
274 if len(parts) == 2 {
275 return &struct {
276 owner string
277 module string
278 }{owner: parts[0], module: parts[1]}
279 }
280 }
281 return nil
282 } else if num == 2 && typ == protowire.BytesType {
283 v, mLen := protowire.ConsumeBytes(msg)
284 msg = msg[mLen:]
285 return parseModuleName(v)
286 }
287 n = protowire.ConsumeFieldValue(num, typ, msg)
288 if n < 0 {
289 return nil
290 }
291 msg = msg[n:]
292 }
293 return nil
294}
295
296func parseModuleName(msg []byte) *struct {
297 owner string

Callers 1

ServeGetModulesMethod · 0.85

Calls 1

parseModuleNameFunction · 0.85

Tested by

no test coverage detected