Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions modules/bidResponseFilter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ export function addBidResponseHook(next, adUnitCode, bid, reject, index = auctio
const mediaTypesConfig = {enforce: true, blockUnknown: true, ...(moduleConfig?.mediaTypes || {})};

const {
primaryCatId, secondaryCatIds = [],
advertiserDomains = [],
attr: metaAttr,
mediaType: metaMediaType,
} = bid.meta || {};
meta: {
primaryCatId, secondaryCatIds = [],
advertiserDomains = [],
attr: metaAttr
} = {}
} = bid;

// checking if bid fulfills ortb2 fields rules
if ((catConfig.enforce && bcat.some(category => [primaryCatId, ...secondaryCatIds].includes(category))) ||
Expand Down
10 changes: 5 additions & 5 deletions test/spec/modules/bidResponseFilter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ describe('bidResponseFilter', () => {
})

const bid = {
mediaType: 'banner',
meta: {
advertiserDomains: ['domain1.com', 'domain2.com'],
primaryCatId: 'EXAMPLE-CAT-ID',
attr: 'attr',
mediaType: 'banner'
}
};

Expand Down Expand Up @@ -118,12 +118,12 @@ describe('bidResponseFilter', () => {
const reject = sinon.stub();
const call = sinon.stub();
const bid = {
mediaType: 'video',
meta: {
advertiserDomains: ['validdomain1.com', 'validdomain2.com'],
primaryCatId: 'VALID_CAT',
attr: 'BANNED_ATTR'
},
mediaType: 'video'
};
mockAuctionIndex.getOrtb2 = () => ({
badv: ['domain2.com'], bcat: ['BANNED_CAT1', 'BANNED_CAT2']
Expand All @@ -144,11 +144,11 @@ describe('bidResponseFilter', () => {
it('should omit the validation if the flag is set to false', () => {
const call = sinon.stub();
const bid = {
mediaType: 'banner',
meta: {
advertiserDomains: ['validdomain1.com', 'validdomain2.com'],
primaryCatId: 'BANNED_CAT1',
attr: 'valid_attr',
mediaType: 'banner',
}
};

Expand All @@ -173,11 +173,11 @@ describe('bidResponseFilter', () => {
it('should allow bid for unknown flag set to false', () => {
const call = sinon.stub();
const bid = {
mediaType: 'banner',
meta: {
advertiserDomains: ['validdomain1.com', 'validdomain2.com'],
primaryCatId: undefined,
attr: 'valid_attr',
mediaType: 'banner'
}
};

Expand All @@ -203,11 +203,11 @@ describe('bidResponseFilter', () => {
const reject = sinon.stub();
const call = sinon.stub();
const bid = {
mediaType: 'audio',
meta: {
advertiserDomains: ['validdomain1.com', 'validdomain2.com'],
primaryCatId: 'VALID_CAT',
attr: 6,
mediaType: 'audio'
},
};

Expand Down
Loading