diff --git a/modules/zeta_global_sspBidAdapter.js b/modules/zeta_global_sspBidAdapter.js index 5d16a469153..722c51dc058 100644 --- a/modules/zeta_global_sspBidAdapter.js +++ b/modules/zeta_global_sspBidAdapter.js @@ -141,7 +141,7 @@ export const spec = { }; const rInfo = bidderRequest.refererInfo; // TODO: do the fallbacks make sense here? - payload.site.page = rInfo.page || rInfo.topmostLocation; + payload.site.page = cropPage(rInfo.page || rInfo.topmostLocation); payload.site.domain = parseDomain(payload.site.page, {noLeadingWww: true}); payload.device.ua = navigator.userAgent; @@ -386,6 +386,30 @@ function provideMediaType(zetaBid, bid, bidRequest) { } } +function cropPage(page) { + if (page) { + if (page.length > 100) { + page = page.substring(0, 100); + } + if (page.startsWith('https://')) { + page = page.substring(8); + } else if (page.startsWith('http://')) { + page = page.substring(7); + } + if (page.startsWith('www.')) { + page = page.substring(4); + } + for (let i = 3; i < page.length; i++) { + const c = page[i]; + if (c === '#' || c === '?') { + return page.substring(0, i); + } + } + return page; + } + return ''; +} + function clearEmpties(o) { for (let k in o) { if (o[k] === null) { diff --git a/test/spec/modules/zeta_global_sspBidAdapter_spec.js b/test/spec/modules/zeta_global_sspBidAdapter_spec.js index 7beac2f820c..f9cfe2dde6a 100644 --- a/test/spec/modules/zeta_global_sspBidAdapter_spec.js +++ b/test/spec/modules/zeta_global_sspBidAdapter_spec.js @@ -59,7 +59,7 @@ describe('Zeta Ssp Bid Adapter', function () { sid: 'publisherId', tagid: 'test_tag_id', site: { - page: 'testPage' + page: 'http://www.zetaglobal.com/page?param=value' }, app: { bundle: 'testBundle' @@ -235,7 +235,7 @@ describe('Zeta Ssp Bid Adapter', function () { id: '123', site: { id: 'SITE_ID', - page: 'page.com', + page: 'http://www.zetaglobal.com/page?param=value', domain: 'domain.com' }, user: { @@ -263,7 +263,7 @@ describe('Zeta Ssp Bid Adapter', function () { id: '123', site: { id: 'SITE_ID', - page: 'page.com', + page: 'http://www.zetaglobal.com/page?param=value', domain: 'domain.com' }, user: { @@ -312,7 +312,7 @@ describe('Zeta Ssp Bid Adapter', function () { 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.page).to.eql('zetaglobal.com/page'); expect(payload.site.domain).to.eql('zetaglobal.com'); });