mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 03:24:40 -07:00
Fixes mishandling of an edge condition in the {{Split()}} subject mapping function
This commit is contained in:
@@ -4581,7 +4581,7 @@ func (tr *transform) transform(tokens []string) (string, error) {
|
||||
if split != _EMPTY_ {
|
||||
b.WriteString(split)
|
||||
}
|
||||
if j < len(splits)-1 && splits[j+1] != _EMPTY_ && j != 0 {
|
||||
if j < len(splits)-1 && splits[j+1] != _EMPTY_ && !(j == 0 && split == _EMPTY_) {
|
||||
b.WriteString(tsep)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3335,6 +3335,7 @@ func TestSubjectTransforms(t *testing.T) {
|
||||
shouldMatch("*", "{{SliceFromLeft(1,3)}}", "1234567890", "123.456.789.0")
|
||||
shouldMatch("*", "{{SliceFromRight(1,3)}}", "1234567890", "1.234.567.890")
|
||||
shouldMatch("*", "{{split(1,-)}}", "-abc-def--ghi-", "abc.def.ghi")
|
||||
shouldMatch("*", "{{split(1,-)}}", "abc-def--ghi-", "abc.def.ghi")
|
||||
shouldMatch("*.*", "{{split(2,-)}}.{{splitfromleft(1,2)}}", "foo.-abc-def--ghij-", "abc.def.ghij.fo.o") // combo + checks split for multiple instance of deliminator and deliminator being at the start or end
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user