Skip to content

Commit

Permalink
hb_adid should be uppercase in all cases (prebid#1037)
Browse files Browse the repository at this point in the history
* hb_adid should be uppercase in all cases

* Added unit tests and changed var to let
  • Loading branch information
jaiminpanchal27 authored and Mat Brown committed Mar 20, 2017
1 parent 3974ea2 commit 7eb430a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/targeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ targeting.setTargetingForAst = function() {
utils.logMessage(`Attempting to set targeting for targetId: ${targetId} key: ${key} value: ${targeting[targetId][key]}`);
//setKeywords supports string and array as value
if(utils.isStr(targeting[targetId][key]) || utils.isArray(targeting[targetId][key])) {
var keywordsObj = {};
var nKey = (key === 'hb_adid') ? key.toUpperCase() : key;
let keywordsObj = {};
let input = 'hb_adid';
let nKey = (key.substring(0, input.length) === input) ? key.toUpperCase() : key;
keywordsObj[nKey] = targeting[targetId][key];
window.apntag.setKeywords(targetId,keywordsObj);
}
Expand Down
7 changes: 7 additions & 0 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,13 @@ describe('Unit: Prebid Module', function () {
expect(newAdserverTargeting).to.deep.equal(window.apntag.tags[adUnitCode].keywords);
});

it('should not find hb_adid key in lowercase for all bidders', () => {
const adUnitCode = '/19968336/header-bid-tag-0';
$$PREBID_GLOBAL$$.enableSendAllBids();
$$PREBID_GLOBAL$$.setTargetingForAst();
const keywords = Object.keys(window.apntag.tags[adUnitCode].keywords).filter(keyword => (keyword.substring(0, 'hb_adid'.length) === 'hb_adid'));
expect(keywords.length).to.equal(0);
});
});

});

0 comments on commit 7eb430a

Please sign in to comment.