Skip to content

Commit

Permalink
Merge pull request #3887 from MauriceVanVeen/main
Browse files Browse the repository at this point in the history
[FIXED] Using partition with multiple wildcard token positions
  • Loading branch information
derekcollison committed Feb 20, 2023
2 parents 5c6b3b6 + 05695d3 commit ad8aa7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/accounts.go
Expand Up @@ -4431,7 +4431,9 @@ func newTransform(src, dest string) (*transform, error) {
dtokMappingFunctionIntArgs = append(dtokMappingFunctionIntArgs, -1)
dtokMappingFunctionStringArgs = append(dtokMappingFunctionStringArgs, _EMPTY_)
} else {
nphs++
// We might combine multiple tokens into one, for example with a partition
nphs += len(transformArgWildcardIndexes)

// Now build up our runtime mapping from dest to source tokens.
var stis []int
for _, wildcardIndex := range transformArgWildcardIndexes {
Expand Down
2 changes: 2 additions & 0 deletions server/accounts_test.go
Expand Up @@ -3303,6 +3303,8 @@ func TestSubjectTransforms(t *testing.T) {
shouldBeOK("foo", "bar")
shouldBeOK("foo.*.bar.*.baz", "req.$2.$1")
shouldBeOK("baz.>", "mybaz.>")
shouldBeOK("*.*", "{{partition(10,1,2)}}")
shouldBeOK("foo.*.*", "foo.{{wildcard(1)}}.{{wildcard(2)}}.{{partition(5,1,2)}}")
shouldBeOK("*", "{{splitfromleft(1,1)}}")

shouldMatch := func(src, dest, sample, expected string) {
Expand Down

0 comments on commit ad8aa7c

Please sign in to comment.