Skip to content

Commit

Permalink
remove uri-encoding (#5307)
Browse files Browse the repository at this point in the history
Co-authored-by: Melody Li <melody@yieldmo.com>
  • Loading branch information
MelodyLi2017 and Melody Li authored May 28, 2020
1 parent c577d76 commit 943034e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
14 changes: 6 additions & 8 deletions modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const spec = {
title: localWindow.document.title || '',
w: localWindow.innerWidth,
h: localWindow.innerHeight,
userConsent: encodeURIComponent(
userConsent:
JSON.stringify({
// case of undefined, stringify will remove param
gdprApplies:
Expand All @@ -49,11 +49,10 @@ export const spec = {
bidderRequest && bidderRequest.gdprConsent
? bidderRequest.gdprConsent.consentString
: '',
})
),
}),
us_privacy:
bidderRequest && bidderRequest.uspConsent
? encodeURIComponent(bidderRequest.uspConsent)
? bidderRequest.uspConsent
: '',
};

Expand All @@ -76,12 +75,11 @@ export const spec = {
serverRequest.cri_prebid = criteoId;
}
if (request.schain) {
serverRequest.schain = encodeURIComponent(
JSON.stringify(request.schain)
);
serverRequest.schain =
JSON.stringify(request.schain);
}
});
serverRequest.p = encodeURIComponent('[' + serverRequest.p.toString() + ']');
serverRequest.p = '[' + serverRequest.p.toString() + ']';
return {
method: 'GET',
url: SERVER_ENDPOINT,
Expand Down
18 changes: 9 additions & 9 deletions test/spec/modules/yieldmoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('YieldmoAdapter', function () {
it('should place bid information into the p parameter of data', function () {
let placementInfo = spec.buildRequests(bidArray, bidderRequest).data.p;
expect(placementInfo).to.equal(
encodeURIComponent('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1}]')
'[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1}]'
);
bidArray.push({
bidder: 'yieldmo',
Expand All @@ -117,20 +117,20 @@ describe('YieldmoAdapter', function () {
// multiple placements
placementInfo = spec.buildRequests(bidArray, bidderRequest).data.p;
expect(placementInfo).to.equal(
encodeURIComponent('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1},{"placement_id":"adunit-code-1","callback_id":"123456789","sizes":[[300,250],[300,600]],"bidFloor":0.2}]')
'[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1},{"placement_id":"adunit-code-1","callback_id":"123456789","sizes":[[300,250],[300,600]],"bidFloor":0.2}]'
);
});

it('should add placement id if given', function () {
bidArray[0].params.placementId = 'ym_1293871298';
let placementInfo = spec.buildRequests(bidArray, bidderRequest).data.p;
expect(placementInfo).to.include(encodeURIComponent('"ym_placement_id":"ym_1293871298"'));
expect(placementInfo).not.to.include(encodeURIComponent('"ym_placement_id":"ym_0987654321"'));
expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"');
expect(placementInfo).not.to.include('"ym_placement_id":"ym_0987654321"');

bidArray[1].params.placementId = 'ym_0987654321';
placementInfo = spec.buildRequests(bidArray, bidderRequest).data.p;
expect(placementInfo).to.include(encodeURIComponent('"ym_placement_id":"ym_1293871298"'));
expect(placementInfo).to.include(encodeURIComponent('"ym_placement_id":"ym_0987654321"'));
expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"');
expect(placementInfo).to.include('"ym_placement_id":"ym_0987654321"');
});

it('should add additional information to data parameter of request', function () {
Expand Down Expand Up @@ -230,10 +230,10 @@ describe('YieldmoAdapter', function () {
};
const data = spec.buildRequests(bidArray, bidderRequest).data;
expect(data.userConsent).equal(
encodeURIComponent(JSON.stringify({
JSON.stringify({
gdprApplies: true,
cmp: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
}))
})
);
});

Expand All @@ -252,7 +252,7 @@ describe('YieldmoAdapter', function () {
};
bidArray[0].schain = schain;
const request = spec.buildRequests([bidArray[0]], bidderRequest);
expect(request.data.schain).equal(encodeURIComponent(JSON.stringify(schain)));
expect(request.data.schain).equal(JSON.stringify(schain));
});
});

Expand Down

0 comments on commit 943034e

Please sign in to comment.