Skip to content

Commit

Permalink
fix(adyoulike): use bidderRequest referer info (prebid#3339)
Browse files Browse the repository at this point in the history
  • Loading branch information
j343my authored and Pedro López Jiménez committed Mar 18, 2019
1 parent 2779585 commit 3b853b7
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions modules/adyoulikeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -60,7 +59,7 @@ export const spec = {

return {
method: 'POST',
url: createEndpoint(dcHostname),
url: createEndpoint(bidRequests, bidderRequest),
data,
options
};
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 3b853b7

Please sign in to comment.