Skip to content

Commit

Permalink
[fixed] wildcard counting issue on import validation (#154)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Hanel <mh@synadia.com>
  • Loading branch information
matthiashanel committed Jul 15, 2021
1 parent bd63c2e commit 37a10b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion v2/imports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ func TestImportsLocalSubjectVariants(t *testing.T) {
&Import{Subject: "foo.*.bar.*.>", Account: akp, LocalSubject: "my.$2.$1.>", Type: Stream},
&Import{Subject: "baz.*.bar.*.>", Account: akp, LocalSubject: "bar.*.*.>", Type: Service},
&Import{Subject: "baz.*", Account: akp, LocalSubject: "my.$1", Type: Stream},
&Import{Subject: "bar.*", Account: akp, LocalSubject: "baz.*", Type: Service})
&Import{Subject: "bar.*", Account: akp, LocalSubject: "baz.*", Type: Service},
&Import{Subject: "biz.*.*.*", Account: akp, LocalSubject: "buz.*.*.*", Type: Service})
vr := CreateValidationResults()
imports.Validate("", vr)
if !vr.IsEmpty() {
Expand Down
11 changes: 5 additions & 6 deletions v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,11 @@ func (s Subject) countTokenWildcards() int {
if v == "*" {
return 1
}
cnt := strings.Count(v, ".*.")
if strings.HasSuffix(v, ".*") {
cnt++
}
if strings.HasPrefix(v, "*.") {
cnt++
cnt := 0
for _, t := range strings.Split(v, ".") {
if t == "*" {
cnt++
}
}
return cnt
}
Expand Down

0 comments on commit 37a10b0

Please sign in to comment.