Skip to content

Commit

Permalink
Merge pull request #110 from cgascoig/fix83
Browse files Browse the repository at this point in the history
Don't try to resolve an moid as a name
  • Loading branch information
cgascoig authored Aug 7, 2023
2 parents 1e23918 + a3784e6 commit 586ee1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ func ParseMoRef(moref string) (string, string, bool) {
var r *regexp.Regexp
var m []string

r = regexp.MustCompile(`^[[:xdigit:]]{24}$`)
m = r.FindStringSubmatch(moref)
if m != nil {
return "", "", false
}

r = regexp.MustCompile(`MoRef\[\$filter:(.+)\]`)
m = r.FindStringSubmatch(moref)
if m != nil {
Expand Down
6 changes: 6 additions & 0 deletions pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ func TestParseMoRef(t *testing.T) {
datatype: "",
ok: true,
},
{
moref: "59c84e4a16267c0001c23428",
filter: "",
datatype: "",
ok: false,
},
}

for _, test := range tests {
Expand Down

0 comments on commit 586ee1d

Please sign in to comment.