Skip to content
Open
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
13 changes: 8 additions & 5 deletions modules/dasBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
nativeResponse.clickTrackers = [Thirdpartyclicktracker, thirdPartyClickTracker2].filter(Boolean);

if (dsaurl) {
nativeResponse.privacyLink = dsaurl;

Check warning on line 53 in modules/dasBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

53 line is not covered with tests
}

return nativeResponse;
Expand All @@ -58,12 +58,12 @@

function getGdeScriptUrl(adDataFields) {
if (REQUIRED_GDE_PARAMS.every(param => adDataFields[param])) {
const params = new URLSearchParams();
Object.entries(adDataFields)
.filter(([key]) => key.startsWith(GDE_PARAM_PREFIX))
.forEach(([key, value]) => params.append(key, value));

Check warning on line 64 in modules/dasBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

61-64 lines are not covered with tests

return `${GDE_SCRIPT_URL}?${params.toString()}`;

Check warning on line 66 in modules/dasBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

66 line is not covered with tests
}
return null;
}
Expand Down Expand Up @@ -144,7 +144,7 @@

const dsaRequired = deepAccess(bidderRequest, 'ortb2.regs.ext.dsa.required');
if (dsaRequired !== undefined) {
customParams.dsainfo = dsaRequired;

Check warning on line 147 in modules/dasBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

147 line is not covered with tests
}

return {
Expand All @@ -156,10 +156,10 @@
function buildUserIds(customParams) {
const userIds = {};
if (customParams.lu) {
userIds.lu = customParams.lu;

Check warning on line 159 in modules/dasBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

159 line is not covered with tests
}
if (customParams.aid) {
userIds.aid = customParams.aid;

Check warning on line 162 in modules/dasBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

162 line is not covered with tests
}
return userIds;
}
Expand Down Expand Up @@ -193,7 +193,7 @@
secure: 1,
};
if (bid.params.slotSequence) {
imp.ext = {

Check warning on line 196 in modules/dasBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

196 line is not covered with tests
pos: String(bid.params.slotSequence)
};
}
Expand All @@ -207,7 +207,7 @@
};
}
if (bid.mediaTypes?.native) {
imp.native = {

Check warning on line 210 in modules/dasBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

210 line is not covered with tests
request: '{}',
ver: '1.2',
};
Expand Down Expand Up @@ -248,15 +248,18 @@
request.ext.adbeta = customParams.adbeta;
}

// AdShield anti-adblock recovery signal (set by dlApi as customParams.asd, like adbeta).
// Sent as a plain ext field (not a key-value) so das-bidder serves only
// adblock-compatible demand (adblock_compability == 2).
if (customParams.asd) {
request.ext.asd = customParams.asd;
const adf = parseInt(customParams.adf, 10);
if (Number.isInteger(adf) && adf > 0) {
request.ext.adf = adf;
}

const asd = parseInt(customParams.asd, 10);
if (Number.isInteger(asd) && asd > 0) {
request.ext.asd = asd;
}

if (bidderRequest.device) {
request.device = bidderRequest.device;

Check warning on line 262 in modules/dasBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

262 line is not covered with tests
}

if (bidderRequest.gdprConsent) {
Expand Down
62 changes: 61 additions & 1 deletion test/spec/modules/dasBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ describe('dasBidAdapter', function () {
expect(payload.imp[0].banner.format[0]).to.deep.equal({ w: 300, h: 250 });
});

it('should route customParams.asd into ext.asd for AdShield recovery', function () {
it('should route customParams.asd into ext.asd as an integer', function () {
const asdBidRequests = [{
...bidRequests[0],
params: {
Expand All @@ -204,6 +204,66 @@ describe('dasBidAdapter', function () {
expect(payload.ext.asd).to.be.undefined;
});

it('should route customParams.adf into ext.adf as an integer', function () {
const adfBidRequests = [{
...bidRequests[0],
params: {
...bidRequests[0].params,
customParams: { adf: 1 }
}
}];

const request = spec.buildRequests(adfBidRequests, bidderRequest);
const params = new URLSearchParams(request.url.split('?')[1]);
const payload = JSON.parse(decodeURIComponent(params.get('data')));

expect(payload.ext.adf).to.equal(1);
expect(payload.ext.asd).to.be.undefined;
expect(payload.ext.keyvalues.adf).to.be.undefined;
});

it('should not set ext.adf without customParams.adf', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
const params = new URLSearchParams(request.url.split('?')[1]);
const payload = JSON.parse(decodeURIComponent(params.get('data')));

expect(payload.ext.adf).to.be.undefined;
});

it('should coerce string customParams.adf and customParams.asd to integers', function () {
const stringBidRequests = [{
...bidRequests[0],
params: {
...bidRequests[0].params,
customParams: { adf: '1', asd: '1' }
}
}];

const request = spec.buildRequests(stringBidRequests, bidderRequest);
const params = new URLSearchParams(request.url.split('?')[1]);
const payload = JSON.parse(decodeURIComponent(params.get('data')));

expect(payload.ext.adf).to.equal(1);
expect(payload.ext.asd).to.equal(1);
});

it('should drop non-numeric or zero customParams.adf and customParams.asd', function () {
const badBidRequests = [{
...bidRequests[0],
params: {
...bidRequests[0].params,
customParams: { adf: 'yes', asd: 0 }
}
}];

const request = spec.buildRequests(badBidRequests, bidderRequest);
const params = new URLSearchParams(request.url.split('?')[1]);
const payload = JSON.parse(decodeURIComponent(params.get('data')));

expect(payload.ext.adf).to.be.undefined;
expect(payload.ext.asd).to.be.undefined;
});

it('should use GET method when URL is under 8192 characters', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.method).to.equal('GET');
Expand Down
Loading