Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AdyoulikeAdapter Referer info #3339

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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