Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add crs parameter to eplanning adapter #2682

Merged
merged 1 commit into from
Jun 21, 2018
Merged
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
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