diff --git a/modules/zetaSspBidAdapter.js b/modules/zetaSspBidAdapter.js index c956df55a1f..5e672770b7d 100644 --- a/modules/zetaSspBidAdapter.js +++ b/modules/zetaSspBidAdapter.js @@ -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) { @@ -116,8 +117,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); } @@ -179,4 +181,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); diff --git a/test/spec/modules/zetaSspBidAdapter_spec.js b/test/spec/modules/zetaSspBidAdapter_spec.js index 4602e2d2b77..cf6e8d8f813 100644 --- a/test/spec/modules/zetaSspBidAdapter_spec.js +++ b/test/spec/modules/zetaSspBidAdapter_spec.js @@ -33,7 +33,7 @@ describe('Zeta Ssp Bid Adapter', function() { } }, refererInfo: { - referer: 'zetaglobal.com' + referer: 'http://www.zetaglobal.com/page?param=value' }, params: { placement: 12345, @@ -64,6 +64,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;