From be08dc842a7d5a12ba60fe17a1fd11984cf29e2c Mon Sep 17 00:00:00 2001 From: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Date: Tue, 20 Feb 2024 16:56:03 +0100 Subject: [PATCH] Zeta Global Ssp Adapter: remove null values from payload (#11092) * ZetaGlobalSsp: remove null values from payload * unit test --------- Co-authored-by: Surovenko Alexey Co-authored-by: Alexey Surovenko --- modules/zeta_global_sspBidAdapter.js | 4 ++++ .../modules/zeta_global_sspBidAdapter_spec.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/modules/zeta_global_sspBidAdapter.js b/modules/zeta_global_sspBidAdapter.js index 295108f31b4..af73865c484 100644 --- a/modules/zeta_global_sspBidAdapter.js +++ b/modules/zeta_global_sspBidAdapter.js @@ -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; } diff --git a/test/spec/modules/zeta_global_sspBidAdapter_spec.js b/test/spec/modules/zeta_global_sspBidAdapter_spec.js index b06a6700ebf..81617b93d3c 100644 --- a/test/spec/modules/zeta_global_sspBidAdapter_spec.js +++ b/test/spec/modules/zeta_global_sspBidAdapter_spec.js @@ -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', @@ -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; + }); });