Skip to content

Commit

Permalink
Zeta Ssp Bid Adapter: provide domain in site object (prebid#6928)
Browse files Browse the repository at this point in the history
* Provide domain value in site object

* Support IE11

* Just minor refactor

Co-authored-by: Surovenko Alexey <surovenko.alexey@gmail.com>
  • Loading branch information
2 people authored and agrandes-tappx committed Sep 29, 2021
1 parent 8718c20 commit 7dd41c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
20 changes: 16 additions & 4 deletions modules/zetaSspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ export const spec = {
sid: params.sid ? params.sid : undefined
}
};

const rInfo = bidderRequest.refererInfo;
payload.device.ua = navigator.userAgent;
payload.site.page = bidderRequest.refererInfo.referer;
payload.site.page = (rInfo && rInfo.referer) ? rInfo.referer.trim() : window.location.href;
payload.site.domain = getDomainFromURL(payload.site.page);
payload.site.mobile = /(ios|ipod|ipad|iphone|android)/i.test(navigator.userAgent) ? 1 : 0;

if (params.test) {
Expand Down Expand Up @@ -115,8 +116,9 @@ export const spec = {
netRevenue: NET_REV,
};
if (zetaBid.adomain && zetaBid.adomain.length) {
bid.meta = {};
bid.meta.advertiserDomains = zetaBid.adomain;
bid.meta = {
advertiserDomains: zetaBid.adomain
};
}
bidResponse.push(bid);
}
Expand Down Expand Up @@ -178,4 +180,14 @@ function provideEids(request, payload) {
}
}

function getDomainFromURL(url) {
let anchor = document.createElement('a');
anchor.href = url;
let hostname = anchor.hostname;
if (hostname.indexOf('www.') === 0) {
return hostname.substring(4);
}
return hostname;
}

registerBidder(spec);
9 changes: 8 additions & 1 deletion test/spec/modules/zetaSspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Zeta Ssp Bid Adapter', function() {
}
},
refererInfo: {
referer: 'zetaglobal.com'
referer: 'http://www.zetaglobal.com/page?param=value'
},
gdprConsent: {
gdprApplies: 1,
Expand Down Expand Up @@ -68,6 +68,13 @@ describe('Zeta Ssp Bid Adapter', function() {
expect(payload.user.ext.eids).to.eql(eids);
});

it('Test page and domain in site', function () {
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
const payload = JSON.parse(request.data);
expect(payload.site.page).to.eql('http://www.zetaglobal.com/page?param=value');
expect(payload.site.domain).to.eql('zetaglobal.com');
});

it('Test the request processing function', function () {
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
expect(request).to.not.be.empty;
Expand Down

0 comments on commit 7dd41c9

Please sign in to comment.