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

Rubicon adapter: get referrer from bidderRequest.refererInfo.referer; #3087

Merged
merged 14 commits into from
Sep 28, 2018
8 changes: 4 additions & 4 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const spec = {
let size = parseSizes(bidRequest);

let data = {
page_url: _getPageUrl(bidRequest),
page_url: _getPageUrl(bidRequest, bidderRequest),
resolution: _getScreenResolution(),
account_id: params.accountId,
integration: INTEGRATION,
Expand Down Expand Up @@ -324,7 +324,7 @@ export const spec = {
'p_geo.latitude': isNaN(parseFloat(latitude)) ? undefined : parseFloat(latitude).toFixed(4),
'p_geo.longitude': isNaN(parseFloat(longitude)) ? undefined : parseFloat(longitude).toFixed(4),
'tg_fl.eid': bidRequest.code,
'rf': _getPageUrl(bidRequest)
'rf': _getPageUrl(bidRequest, bidderRequest)
};

if (bidderRequest.gdprConsent) {
Expand Down Expand Up @@ -500,12 +500,12 @@ function _getDigiTrustQueryParams() {
* @param {BidRequest} bidRequest
* @returns {string}
*/
function _getPageUrl(bidRequest) {
function _getPageUrl(bidRequest, bidderRequest) {
let pageUrl = config.getConfig('pageUrl');
if (bidRequest.params.referrer) {
pageUrl = bidRequest.params.referrer;
} else if (!pageUrl) {
pageUrl = utils.getTopWindowUrl();
pageUrl = bidderRequest.refererInfo.referer;
}
return bidRequest.params.secure ? pageUrl.replace(/^http:/i, 'https:') : pageUrl;
}
Expand Down
24 changes: 22 additions & 2 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,33 @@ describe('the rubicon adapter', function () {
});
});

it('page_url should use params.referrer, config.getConfig("pageUrl"), utils.getTopWindowUrl() in that order', function () {
sandbox.stub(utils, 'getTopWindowUrl').callsFake(() => 'http://www.prebid.org');
it('should add referer info to request data', function () {
let refererInfo = {
referer: 'http://www.prebid.org',
reachedTop: true,
numIframes: 1,
stack: [
'http://www.prebid.org/page.html',
'http://www.prebid.org/iframe1.html',
]
};

bidderRequest = Object.assign({refererInfo}, bidderRequest);
delete bidderRequest.bids[0].params.referrer;
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
let data = parseQuery(request.data);

expect(parseQuery(request.data).rf).to.exist;
expect(parseQuery(request.data).rf).to.equal('http://www.prebid.org');
});

it('page_url should use params.referrer, config.getConfig("pageUrl"), bidderRequest.refererInfo in that order', function () {
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
expect(parseQuery(request.data).rf).to.equal('localhost');

delete bidderRequest.bids[0].params.referrer;
let refererInfo = { referer: 'http://www.prebid.org' };
bidderRequest = Object.assign({refererInfo}, bidderRequest);
[request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
expect(parseQuery(request.data).rf).to.equal('http://www.prebid.org');

Expand Down