Skip to content

Commit

Permalink
Addressed some minor code fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankit-Pinge committed Sep 30, 2023
1 parent 972404e commit 51d032d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions adapters/vastbidder/bidder_macro.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -1211,11 +1210,11 @@ func (tag *BidderMacro) MacroKV(key string) string {
return ""
}

values := url.Values{}
keyval := ""
for key, val := range tag.KV {
values.Add(key, fmt.Sprintf("%v", val))
keyval += fmt.Sprintf("%s=%v&", key, val)
}
return values.Encode()
return strings.TrimSuffix(keyval, "&")

}

Expand Down
4 changes: 2 additions & 2 deletions adapters/vastbidder/bidder_macro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ func TestBidderMacroKV(t *testing.T) {
"age": "22",
}},
args: args{key: "kv"},
want: "age=22&name=test",
want: "name=test&age=22",
},
{
name: "Valid_test_with_url",
Expand All @@ -1350,7 +1350,7 @@ func TestBidderMacroKV(t *testing.T) {
"url": "http://example.com?k1=v1&k2=v2",
}},
args: args{key: "kv"},
want: "age=22&name=test&url=http%3A%2F%2Fexample.com%3Fk1%3Dv1%26k2%3Dv2",
want: "name=test&age=22&url=http://example.com?k1=v1&k2=v2",
},
{
name: "Empty_KV_map",
Expand Down

0 comments on commit 51d032d

Please sign in to comment.