diff --git a/adapters/pubmatic/pubmatic.go b/adapters/pubmatic/pubmatic.go index a4c4e222210..2dfba673734 100644 --- a/adapters/pubmatic/pubmatic.go +++ b/adapters/pubmatic/pubmatic.go @@ -471,7 +471,7 @@ func parseImpressionObject(imp *openrtb.Imp, wrapExt *string, pubID *string) err } if *pubID == "" { - *pubID = pubmaticExt.PublisherId + *pubID = strings.TrimSpace(pubmaticExt.PublisherId) } // Parse Wrapper Extension only once per request diff --git a/adapters/pubmatic/pubmatic_test.go b/adapters/pubmatic/pubmatic_test.go index 8ed2ccd391c..21eb56806de 100644 --- a/adapters/pubmatic/pubmatic_test.go +++ b/adapters/pubmatic/pubmatic_test.go @@ -20,6 +20,8 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/prebid-server/pbs" "github.com/prebid/prebid-server/usersync" + + "github.com/stretchr/testify/assert" ) func TestJsonSamples(t *testing.T) { @@ -728,3 +730,36 @@ func TestGetBidTypeForUnsupportedCode(t *testing.T) { t.Errorf("Expected Bid Type value was: %v, actual value is: %v", openrtb_ext.BidTypeBanner, actualBidTypeValue) } } + +func TestMakeRequestsTrimsPubID(t *testing.T) { + var a PubmaticAdapter + a.URI = "http://test.com/openrtb2" + + var bidderExt adapters.ExtImpBidder + extImpPubMatic := openrtb_ext.ExtImpPubmatic{} + extImpPubMatic.PublisherId = " 5890 " + bidderExt.Bidder, _ = json.Marshal(extImpPubMatic) + extRaw, _ := json.Marshal(bidderExt) + + var w, h uint64 + w = 300 + h = 250 + var impression = openrtb.Imp{ + Banner: &openrtb.Banner{ + W: &w, + H: &h, + }, + Ext: extRaw, + } + request := &openrtb.BidRequest{ + Imp: []openrtb.Imp{impression}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{}, + }, + } + a.MakeRequests(request, nil) + + updatedPubID := request.Site.Publisher.ID + + assert.Equal(t, "5890", updatedPubID, "Publisher.ID field should be trimmed") +} \ No newline at end of file