MCPcopy
hub / github.com/wavetermdev/waveterm / ParseORef

Function ParseORef

pkg/waveobj/waveobj.go:80–98  ·  view source on GitHub ↗
(orefStr string)

Source from the content-addressed store, hash-verified

78var otypeRe = regexp.MustCompile(`^[a-z]+$`)
79
80func ParseORef(orefStr string) (ORef, error) {
81 fields := strings.Split(orefStr, ":")
82 if len(fields) != 2 {
83 return ORef{}, fmt.Errorf("invalid object reference: %q", orefStr)
84 }
85 otype := fields[0]
86 if !otypeRe.MatchString(otype) {
87 return ORef{}, fmt.Errorf("invalid object type: %q", otype)
88 }
89 if !ValidOTypes[otype] {
90 return ORef{}, fmt.Errorf("unknown object type: %q", otype)
91 }
92 oid := fields[1]
93 _, err := uuid.Parse(oid)
94 if err != nil {
95 return ORef{}, fmt.Errorf("invalid object id: %q", oid)
96 }
97 return ORef{OType: otype, OID: oid}, nil
98}
99
100func ParseORefNoErr(orefStr string) *ORef {
101 oref, err := ParseORef(orefStr)

Callers 9

parseSimpleIdFunction · 0.92
resolveORefFunction · 0.92
convertSpecialFunction · 0.92
DBFindTabForBlockIdFunction · 0.92
handleBadgeEventFunction · 0.92
isFullORefFunction · 0.92
resolveSimpleIdFunction · 0.92
UnmarshalJSONMethod · 0.85
ParseORefNoErrFunction · 0.85

Calls 1

ParseMethod · 0.80

Tested by

no test coverage detected