Skip to content

Commit

Permalink
PBS Bid Adapter: do not pass aspectratios in ORTB2 ext data if native…
Browse files Browse the repository at this point in the history
… image definition doesn't have ratio_height/ratio_width (prebid#7722)

* Prebid server adapter: do not pass aspectratios in ORTB2 ext data if native image definition does not have ratio_height/ratio_width

* Prebid server adapter: include all valid aspect ratios in ext.aspectratios
  • Loading branch information
dgirardi authored and Chris Pabst committed Jan 10, 2022
1 parent 3d9a7b1 commit 64fa293
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
11 changes: 7 additions & 4 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,13 @@ const OPEN_RTB_PROTOCOL = {
}
if (Array.isArray(params.aspect_ratios)) {
// pass aspect_ratios as ext data I guess?
asset.ext = {
aspectratios: params.aspect_ratios.map(
ratio => `${ratio.ratio_width}:${ratio.ratio_height}`
)
const aspectRatios = params.aspect_ratios
.filter((ar) => ar.ratio_width && ar.ratio_height)
.map(ratio => `${ratio.ratio_width}:${ratio.ratio_height}`);
if (aspectRatios.length > 0) {
asset.ext = {
aspectratios: aspectRatios
}
}
}
assets.push(newAsset({
Expand Down
13 changes: 13 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import events from 'src/events.js';
import CONSTANTS from 'src/constants.json';
import { server } from 'test/mocks/xhr.js';
import { createEidsArray } from 'modules/userId/eids.js';
import {deepAccess, deepClone} from 'src/utils.js';

let CONFIG = {
accountId: '1',
Expand Down Expand Up @@ -1092,6 +1093,18 @@ describe('S2S Adapter', function () {
});
});

it('should not include ext.aspectratios if adunit\'s aspect_ratios do not define radio_width and ratio_height', () => {
const req = deepClone(REQUEST);
req.ad_units[0].mediaTypes.native.icon.aspect_ratios[0] = {'min_width': 1, 'min_height': 2};
adapter.callBids(req, BID_REQUESTS, addBidResponse, done, ajax);
const nativeReq = JSON.parse(JSON.parse(server.requests[0].requestBody).imp[0].native.request);
const icons = nativeReq.assets.map((a) => a.img).filter((img) => img && img.type === 1);
expect(icons).to.have.length(1);
expect(icons[0].hmin).to.equal(2);
expect(icons[0].wmin).to.equal(1);
expect(deepAccess(icons[0], 'ext.aspectratios')).to.be.undefined;
})

it('adds site if app is not present', function () {
const _config = {
s2sConfig: CONFIG,
Expand Down

0 comments on commit 64fa293

Please sign in to comment.