From 06ac80cdbeaa2a58ab05fe932608b3da9b9836f7 Mon Sep 17 00:00:00 2001 From: Matthias Hanel Date: Thu, 22 Jul 2021 11:25:56 -0400 Subject: [PATCH] Review comments Signed-off-by: Matthias Hanel --- server/accounts_test.go | 2 +- server/client.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) 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 {