Skip to content

Commit

Permalink
Use escaped ampersand for multiple arrays.
Browse files Browse the repository at this point in the history
  • Loading branch information
donatwork committed Dec 9, 2024
1 parent 9eca8c2 commit e7735dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions service/preinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *service) PreInit() error {
for _, connectionData := range arrayConfig {
if connectionData.Mdm != "" {
if sb.Len() > 0 {
sb.WriteString("&")
sb.WriteString("\\&")
}
sb.WriteString(connectionData.Mdm)
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func getMdmList(connectionData []*ArrayConnectionData, key, zone string) (string
for _, connectionData := range connectionData {
if connectionData.Mdm != "" && connectionData.Zone.LabelKey == key && connectionData.Zone.Name == zone {
if sb.Len() > 0 {
sb.WriteString("&")
sb.WriteString("\\&")
}
sb.WriteString(connectionData.Mdm)
}
Expand Down
6 changes: 3 additions & 3 deletions service/preinit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestPreInit(t *testing.T) {
},
},
errorExpected: false,
expectedResult: "192.168.1.1,192.168.1.2&192.168.2.1,192.168.2.2",
expectedResult: "192.168.1.1,192.168.1.2\\&192.168.2.1,192.168.2.2",
},
{
name: "should fail if zones configured but unable to fetch node labels",
Expand Down Expand Up @@ -353,7 +353,7 @@ func TestGetMdmList(t *testing.T) {
key: "testKey",
zone: "testZone",
errorExpected: false,
expectedResult: "192.168.0.10,192.168.0.20&192.168.1.10,192.168.1.20",
expectedResult: "192.168.0.10,192.168.0.20\\&192.168.1.10,192.168.1.20",
},
{
name: "two arrays with one MDM each",
Expand All @@ -372,7 +372,7 @@ func TestGetMdmList(t *testing.T) {
key: "testKey",
zone: "testZone",
errorExpected: false,
expectedResult: "192.168.0.10&192.168.1.10",
expectedResult: "192.168.0.10\\&192.168.1.10",
},
{
name: "two arrays with multiple zones 1",
Expand Down

0 comments on commit e7735dc

Please sign in to comment.