diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 625b5e253f59..795c75ef9bc1 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -22,7 +22,6 @@ export const tripleliftAdapterSpec = { tlCall = utils.tryAppendQueryString(tlCall, 'lib', 'prebid'); tlCall = utils.tryAppendQueryString(tlCall, 'v', '$prebid.version$'); - // tlCall = utils.tryAppendQueryString(tlCall, 'fe', _isFlashEnabled().toString()); tlCall = utils.tryAppendQueryString(tlCall, 'referrer', referrer); if (bidderRequest && bidderRequest.timeout) { @@ -93,7 +92,8 @@ function _buildPostBody(bidRequests) { } function _sizes(sizeArray) { - return sizeArray.map(function(size) { + let sizes = sizeArray.filter(_isValidSize); + return sizes.map(function(size) { return { w: size[0], h: size[1] @@ -101,6 +101,10 @@ function _sizes(sizeArray) { }); } +function _isValidSize(size) { + return (size.length === 2 && typeof size[0] === 'number' && typeof size[1] === 'number'); +} + function _buildResponseObject(bidderRequest, bid) { let bidResponse = {}; let width = bid.width || 1; @@ -125,16 +129,4 @@ function _buildResponseObject(bidderRequest, bid) { return bidResponse; } -// function _isFlashEnabled() { -// let flash; -// try { -// flash = Boolean(new ActiveXObject('ShockwaveFlash.ShockwaveFlash')); -// } catch (e) { -// flash = navigator.mimeTypes && -// navigator.mimeTypes['application/x-shockwave-flash'] !== undefined && -// navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin ? 1 : 0 -// } -// return flash ? 1 : 0; -// } - registerBidder(tripleliftAdapterSpec); diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index c7c023ed7266..ed343f1ebf98 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -61,7 +61,7 @@ describe('triplelift adapter', () => { floor: 1.0, }, adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], bidId: '30b31c1838de1e', bidderRequestId: '22edbae2733bf6', auctionId: '1d1a030790a475', @@ -73,6 +73,12 @@ describe('triplelift adapter', () => { expect(request).to.exist.and.to.be.a('object'); }); + it('should only parse sizes that are of the proper length and format', () => { + const request = tripleliftAdapterSpec.buildRequests(bidRequests); + expect(request.data.imp[0].banner.format).to.have.length(2); + expect(request.data.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + }); + it('should be a post request and populate the payload', () => { const request = tripleliftAdapterSpec.buildRequests(bidRequests); const payload = request.data;