Skip to content

Commit

Permalink
Add crs parameter to eplanning adapter (#2682)
Browse files Browse the repository at this point in the history
  • Loading branch information
matimar authored and snapwich committed Jun 21, 2018
1 parent 4723710 commit af9b294
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
16 changes: 16 additions & 0 deletions modules/eplanningBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ export const spec = {
isBidRequestValid: function(bid) {
return Boolean(bid.params.ci) || Boolean(bid.params.t);
},

buildRequests: function(bidRequests) {
const method = 'GET';
const dfpClientId = '1';
const sec = 'ROS';
let url;
let params;
const urlConfig = getUrlConfig(bidRequests);
const pcrs = getCharset();

if (urlConfig.t) {
url = urlConfig.isv + '/layers/t_pbjs_2.json';
Expand All @@ -40,6 +42,11 @@ export const spec = {
pbv: '$prebid.version$',
ncb: '1'
};

if (pcrs) {
params.crs = pcrs;
}

if (referrerUrl) {
params.fr = referrerUrl;
}
Expand Down Expand Up @@ -147,6 +154,15 @@ function getSpacesString(bids) {

return spacesString;
}

function getCharset() {
try {
return window.top.document.charset || window.top.document.characterSet;
} catch (e) {
return document.charset || document.characterSet;
}
}

function getBidIdMap(bidRequests) {
let map = {};
bidRequests.forEach(bid => map[cleanName(bid.adUnitCode)] = bid.bidId);
Expand Down
13 changes: 13 additions & 0 deletions test/spec/modules/eplanningBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,19 @@ describe('E-Planning Adapter', () => {
stubGetReferrer.restore()
});

it('should return crs parameter with document charset', () => {
let expected;
try {
expected = window.top.document.characterSet;
} catch (e) {
expected = document.characterSet;
}

const chset = spec.buildRequests(bidRequests).data.crs;

expect(chset).to.equal(expected);
});

it('should return the testing url when the request has the t parameter', () => {
const url = spec.buildRequests([testBid]).url;
const expectedUrl = '//' + TEST_ISV + '/layers/t_pbjs_2.json';
Expand Down

0 comments on commit af9b294

Please sign in to comment.