Skip to content

Commit

Permalink
Zeta Global Ssp Adapter: remove null values from payload (prebid#11092)
Browse files Browse the repository at this point in the history
* ZetaGlobalSsp: remove null values from payload

* unit test

---------

Co-authored-by: Surovenko Alexey <[email protected]>
Co-authored-by: Alexey Surovenko <[email protected]>
  • Loading branch information
3 people authored Feb 20, 2024
1 parent 7995508 commit be08dc8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/zeta_global_sspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ function provideMediaType(zetaBid, bid, bidRequest) {

function clearEmpties(o) {
for (let k in o) {
if (o[k] === null) {
delete o[k];
continue;
}
if (!o[k] || typeof o[k] !== 'object') {
continue;
}
Expand Down
17 changes: 17 additions & 0 deletions test/spec/modules/zeta_global_sspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ describe('Zeta Ssp Bid Adapter', function () {
},
tags: {
someTag: 444,
emptyTag: {},
nullTag: null,
complexEmptyTag: {
empty: {},
nullValue: null
}
},
sid: 'publisherId',
tagid: 'test_tag_id',
Expand Down Expand Up @@ -657,4 +663,15 @@ describe('Zeta Ssp Bid Adapter', function () {
expect(payload.device.w).to.not.be.undefined;
expect(payload.device.h).to.not.be.undefined;
});

it('Test that all empties are removed', function () {
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
const payload = JSON.parse(request.data);

expect(payload.ext.tags.someTag).to.eql(444);

expect(payload.ext.tags.emptyTag).to.be.undefined;
expect(payload.ext.tags.nullTag).to.be.undefined;
expect(payload.ext.tags.complexEmptyTag).to.be.undefined;
});
});

0 comments on commit be08dc8

Please sign in to comment.