diff --git a/modules/dasBidAdapter.js b/modules/dasBidAdapter.js index 53b0ee92033..81f31be99c8 100644 --- a/modules/dasBidAdapter.js +++ b/modules/dasBidAdapter.js @@ -248,11 +248,14 @@ function buildOpenRTBRequest(bidRequests, bidderRequest) { request.ext.adbeta = customParams.adbeta; } - // AdShield anti-adblock recovery signal (set by dlApi as customParams.asd, like adbeta). - // Sent as a plain ext field (not a key-value) so das-bidder serves only - // adblock-compatible demand (adblock_compability == 2). - if (customParams.asd) { - request.ext.asd = customParams.asd; + const adf = parseInt(customParams.adf, 10); + if (Number.isInteger(adf) && adf > 0) { + request.ext.adf = adf; + } + + const asd = parseInt(customParams.asd, 10); + if (Number.isInteger(asd) && asd > 0) { + request.ext.asd = asd; } if (bidderRequest.device) { diff --git a/test/spec/modules/dasBidAdapter_spec.js b/test/spec/modules/dasBidAdapter_spec.js index d8252171945..a18a2a3b9cb 100644 --- a/test/spec/modules/dasBidAdapter_spec.js +++ b/test/spec/modules/dasBidAdapter_spec.js @@ -179,7 +179,7 @@ describe('dasBidAdapter', function () { expect(payload.imp[0].banner.format[0]).to.deep.equal({ w: 300, h: 250 }); }); - it('should route customParams.asd into ext.asd for AdShield recovery', function () { + it('should route customParams.asd into ext.asd as an integer', function () { const asdBidRequests = [{ ...bidRequests[0], params: { @@ -204,6 +204,66 @@ describe('dasBidAdapter', function () { expect(payload.ext.asd).to.be.undefined; }); + it('should route customParams.adf into ext.adf as an integer', function () { + const adfBidRequests = [{ + ...bidRequests[0], + params: { + ...bidRequests[0].params, + customParams: { adf: 1 } + } + }]; + + const request = spec.buildRequests(adfBidRequests, bidderRequest); + const params = new URLSearchParams(request.url.split('?')[1]); + const payload = JSON.parse(decodeURIComponent(params.get('data'))); + + expect(payload.ext.adf).to.equal(1); + expect(payload.ext.asd).to.be.undefined; + expect(payload.ext.keyvalues.adf).to.be.undefined; + }); + + it('should not set ext.adf without customParams.adf', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const params = new URLSearchParams(request.url.split('?')[1]); + const payload = JSON.parse(decodeURIComponent(params.get('data'))); + + expect(payload.ext.adf).to.be.undefined; + }); + + it('should coerce string customParams.adf and customParams.asd to integers', function () { + const stringBidRequests = [{ + ...bidRequests[0], + params: { + ...bidRequests[0].params, + customParams: { adf: '1', asd: '1' } + } + }]; + + const request = spec.buildRequests(stringBidRequests, bidderRequest); + const params = new URLSearchParams(request.url.split('?')[1]); + const payload = JSON.parse(decodeURIComponent(params.get('data'))); + + expect(payload.ext.adf).to.equal(1); + expect(payload.ext.asd).to.equal(1); + }); + + it('should drop non-numeric or zero customParams.adf and customParams.asd', function () { + const badBidRequests = [{ + ...bidRequests[0], + params: { + ...bidRequests[0].params, + customParams: { adf: 'yes', asd: 0 } + } + }]; + + const request = spec.buildRequests(badBidRequests, bidderRequest); + const params = new URLSearchParams(request.url.split('?')[1]); + const payload = JSON.parse(decodeURIComponent(params.get('data'))); + + expect(payload.ext.adf).to.be.undefined; + expect(payload.ext.asd).to.be.undefined; + }); + it('should use GET method when URL is under 8192 characters', function () { const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.method).to.equal('GET');