From 03da61efa5360a43169f0b29ff3650f85668c48a Mon Sep 17 00:00:00 2001 From: Jeremy Hernandez Date: Mon, 3 Dec 2018 19:01:07 +0100 Subject: [PATCH] fix(adyoulike): use bidderRequest referer info (#3339) --- modules/adyoulikeBidAdapter.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index b9f57115e218..d0ca4e07d081 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -31,7 +31,6 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function (bidRequests, bidderRequest) { - let dcHostname = getHostname(bidRequests); const payload = { Version: VERSION, Bids: bidRequests.reduce((accumulator, bid) => { @@ -60,7 +59,7 @@ export const spec = { return { method: 'POST', - url: createEndpoint(dcHostname), + url: createEndpoint(bidRequests, bidderRequest), data, options }; @@ -94,14 +93,10 @@ function getHostname(bidderRequest) { } /* Get current page referrer url */ -function getReferrerUrl() { +function getReferrerUrl(bidderRequest) { let referer = ''; - if (window.self !== window.top) { - try { - referer = window.top.document.referrer; - } catch (e) { } - } else { - referer = document.referrer; + if (bidderRequest && bidderRequest.refererInfo) { + referer = encodeURIComponent(bidderRequest.refererInfo.referer); } return referer; } @@ -134,20 +129,21 @@ function getPageRefreshed() { } /* Create endpoint url */ -function createEndpoint(host) { +function createEndpoint(bidRequests, bidderRequest) { + let host = getHostname(bidRequests); return format({ protocol: (document.location.protocol === 'https:') ? 'https' : 'http', host: `${DEFAULT_DC}${host}.omnitagjs.com`, pathname: '/hb-api/prebid/v1', - search: createEndpointQS() + search: createEndpointQS(bidderRequest) }); } /* Create endpoint query string */ -function createEndpointQS() { +function createEndpointQS(bidderRequest) { const qs = {}; - const ref = getReferrerUrl(); + const ref = getReferrerUrl(bidderRequest); if (ref) { qs.RefererUrl = encodeURIComponent(ref); }