From ab86b9b1e582fe8ac0b36716896f0489bec64f76 Mon Sep 17 00:00:00 2001 From: Surovenko Alexey Date: Thu, 3 Jun 2021 14:26:12 +0600 Subject: [PATCH 1/3] Provide domain value in site object --- modules/zetaSspBidAdapter.js | 15 +++++++++++++-- test/spec/modules/zetaSspBidAdapter_spec.js | 9 ++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/modules/zetaSspBidAdapter.js b/modules/zetaSspBidAdapter.js index c956df55a1f..324c909f683 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) { @@ -179,4 +180,14 @@ function provideEids(request, payload) { } } +function getDomainFromURL(url) { + let anchor = document.createElement('a'); + anchor.href = url; + let hostname = anchor.hostname; + if (hostname.startsWith('www.')) { + 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; From 5330ca9af8ea84049e61077367ef9f82200036b6 Mon Sep 17 00:00:00 2001 From: Surovenko Alexey Date: Fri, 4 Jun 2021 02:00:46 +0600 Subject: [PATCH 2/3] Support IE11 --- modules/zetaSspBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/zetaSspBidAdapter.js b/modules/zetaSspBidAdapter.js index 324c909f683..6120193b65e 100644 --- a/modules/zetaSspBidAdapter.js +++ b/modules/zetaSspBidAdapter.js @@ -184,7 +184,7 @@ function getDomainFromURL(url) { let anchor = document.createElement('a'); anchor.href = url; let hostname = anchor.hostname; - if (hostname.startsWith('www.')) { + if (hostname.indexOf('www.') === 0) { return hostname.substring(4); } return hostname; From f888cd26221bc830b00587a2c0dc184110ab452b Mon Sep 17 00:00:00 2001 From: Surovenko Alexey Date: Fri, 4 Jun 2021 02:05:07 +0600 Subject: [PATCH 3/3] Just minor refactor --- modules/zetaSspBidAdapter.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/zetaSspBidAdapter.js b/modules/zetaSspBidAdapter.js index 6120193b65e..5e672770b7d 100644 --- a/modules/zetaSspBidAdapter.js +++ b/modules/zetaSspBidAdapter.js @@ -117,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); }