diff --git a/modules/adheseBidAdapter.js b/modules/adheseBidAdapter.js index daea17a2a5b..6ca8c8a6aa6 100644 --- a/modules/adheseBidAdapter.js +++ b/modules/adheseBidAdapter.js @@ -18,13 +18,15 @@ export const spec = { if (validBidRequests.length === 0) { return null; } + const { gdprConsent, refererInfo } = bidderRequest; const account = getAccount(validBidRequests); const targets = validBidRequests.map(bid => bid.params.data).reduce(mergeTargets, {}); - const gdprParams = (bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString) ? [ 'xt' + bidderRequest.gdprConsent.consentString ] : []; + const gdprParams = (gdprConsent && gdprConsent.consentString) ? [`xt${gdprConsent.consentString}`] : []; + const refererParams = (refererInfo && refererInfo.referer) ? [`xf${base64urlEncode(refererInfo.referer)}`] : []; const targetsParams = Object.keys(targets).map(targetCode => targetCode + targets[targetCode].join(';')); const slotsParams = validBidRequests.map(bid => 'sl' + bidToSlotName(bid)); - const params = [...slotsParams, ...targetsParams, ...gdprParams].map(s => '/' + s).join(''); + const params = [...slotsParams, ...targetsParams, ...gdprParams, ...refererParams].map(s => `/${s}`).join(''); const cacheBuster = '?t=' + new Date().getTime(); const uri = 'https://ads-' + account + '.adhese.com/json' + params + cacheBuster; @@ -166,4 +168,8 @@ function getAdDetails(ad) { return { creativeId: creativeId, dealId: dealId }; } +function base64urlEncode(s) { + return btoa(s).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); +} + registerBidder(spec); diff --git a/test/spec/modules/adheseBidAdapter_spec.js b/test/spec/modules/adheseBidAdapter_spec.js index 68beedd4b35..348fb772319 100644 --- a/test/spec/modules/adheseBidAdapter_spec.js +++ b/test/spec/modules/adheseBidAdapter_spec.js @@ -64,6 +64,9 @@ describe('AdheseAdapter', function () { gdprConsent: { gdprApplies: true, consentString: 'CONSENT_STRING' + }, + refererInfo: { + referer: 'http://prebid.org/dev-docs/subjects?_d=1' } }; @@ -91,6 +94,12 @@ describe('AdheseAdapter', function () { expect(req.url).to.contain('/xtCONSENT_STRING'); }); + it('should include referer param in base64url format', function () { + let req = spec.buildRequests([ minimalBid() ], bidderRequest); + + expect(req.url).to.contain('/xfaHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc3ViamVjdHM_X2Q9MQ'); + }); + it('should include bids', function () { let bid = minimalBid(); let req = spec.buildRequests([ bid ], bidderRequest);