From c2dde47eec7e88cd9f0f3a5647036e64c1627993 Mon Sep 17 00:00:00 2001 From: Jeremy Hernandez Date: Thu, 29 Nov 2018 12:30:37 +0100 Subject: [PATCH] fix(adyoulike): use bidderRequest referer info --- modules/adyoulikeBidAdapter.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index b9f57115e21..d0ca4e07d08 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); }