diff --git a/server/accounts_test.go b/server/accounts_test.go index 9e010122..0b952fe6 100644 --- a/server/accounts_test.go +++ b/server/accounts_test.go @@ -3346,7 +3346,7 @@ func TestImportSubscriptionPartialOverlapWithPrefix(t *testing.T) { } func TestImportSubscriptionPartialOverlapWithTransform(t *testing.T) { - cf := createConfFile(t, []byte(fmt.Sprintf(importSubscriptionOverlapTemplate, "*.*.>", "*.*.>", " to: myprefix.$2.$1.>"))) + cf := createConfFile(t, []byte(fmt.Sprintf(importSubscriptionOverlapTemplate, "*.*.>", "*.*.>", "to: myprefix.$2.$1.>"))) defer removeFile(t, cf) s, opts := RunServerWithConfig(cf) diff --git a/server/client.go b/server/client.go index f99e012e..4886369b 100644 --- a/server/client.go +++ b/server/client.go @@ -2509,9 +2509,10 @@ func (c *client) addShadowSubscriptions(acc *Account, sub *subscription) error { for _, tk := range tokens { if tk == pwcs { hasWC = true + break } } - if tokens[len(tokens)-1] == fwcs { + if !hasWC && tokens[len(tokens)-1] == fwcs { hasWC = true } } @@ -2524,7 +2525,7 @@ func (c *client) addShadowSubscriptions(acc *Account, sub *subscription) error { continue } if subj == im.to { - ims = append(ims, ime{im, "", false}) + ims = append(ims, ime{im, _EMPTY_, false}) continue } if tokensModified { @@ -2537,10 +2538,10 @@ func (c *client) addShadowSubscriptions(acc *Account, sub *subscription) error { tokenizeSubjectIntoSlice(im.to, &imTokens) if isSubsetMatchTokenized(tokens, imTokens) { - ims = append(ims, ime{im, "", true}) + ims = append(ims, ime{im, _EMPTY_, true}) } else if hasWC { if isSubsetMatchTokenized(imTokens, tokens) { - ims = append(ims, ime{im, "", false}) + ims = append(ims, ime{im, _EMPTY_, false}) } else { imTokensLen := len(imTokens) for i, t := range tokens {