diff --git a/src/targeting.js b/src/targeting.js index 0ca9f949a64..ae54cf26bf6 100644 --- a/src/targeting.js +++ b/src/targeting.js @@ -210,7 +210,13 @@ export function newTargeting(auctionManager) { // setKeywords supports string and array as value if (utils.isStr(astTargeting[targetId][key]) || utils.isArray(astTargeting[targetId][key])) { let keywordsObj = {}; - keywordsObj[key.toUpperCase()] = astTargeting[targetId][key]; + let regex = /pt[0-9]/; + if (key.search(regex) < 0) { + keywordsObj[key.toUpperCase()] = astTargeting[targetId][key]; + } else { + // pt${n} keys should not be uppercased + keywordsObj[key] = astTargeting[targetId][key]; + } window.apntag.setKeywords(targetId, keywordsObj); } }) diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index 4c72917d7a7..826f3fdc8f0 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -1812,7 +1812,10 @@ describe('Unit: Prebid Module', function () { resetAuction(); auctionManagerInstance = newAuctionManager(); sinon.stub(auctionManagerInstance, 'getBidsReceived').callsFake(function() { - return [getBidResponses()[1]]; + let bidResponse = getBidResponses()[1]; + // add a pt0 value for special case. + bidResponse.adserverTargeting.pt0 = 'someVal'; + return [bidResponse]; }); sinon.stub(auctionManagerInstance, 'getAdUnitCodes').callsFake(function() { return ['/19968336/header-bid-tag-0']; @@ -1832,10 +1835,15 @@ describe('Unit: Prebid Module', function () { var expectedAdserverTargeting = bids[0].adserverTargeting; var newAdserverTargeting = {}; + let regex = /pt[0-9]/; + for (var key in expectedAdserverTargeting) { - newAdserverTargeting[key.toUpperCase()] = expectedAdserverTargeting[key]; + if (key.search(regex) < 0) { + newAdserverTargeting[key.toUpperCase()] = expectedAdserverTargeting[key]; + } else { + newAdserverTargeting[key] = expectedAdserverTargeting[key]; + } } - targeting.setTargetingForAst(); expect(newAdserverTargeting).to.deep.equal(window.apntag.tags[adUnitCode].keywords); });