Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXED] Using partition with multiple wildcard token positions #3887

Merged
merged 1 commit into from Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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