Skip to content

Commit

Permalink
send url as it is (prebid#3116)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaiminpanchal27 authored and SublimeJeremy committed Oct 1, 2018
1 parent 212a63a commit 616d306
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
4 changes: 2 additions & 2 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ export const spec = {

if (bidderRequest && bidderRequest.refererInfo) {
let refererinfo = {
rd_ref: bidderRequest.refererInfo.referer,
rd_ref: encodeURIComponent(bidderRequest.refererInfo.referer),
rd_top: bidderRequest.refererInfo.reachedTop,
rd_ifs: bidderRequest.refererInfo.numIframes,
rd_stk: bidderRequest.refererInfo.stack.join(',')
rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',')
}
payload.referrer_detection = refererinfo;
}
Expand Down
16 changes: 6 additions & 10 deletions src/refererDetection.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function detectReferer(win) {
function getPubUrlStack(levels) {
let stack = [];
let defUrl = null;
let encodedUrl = null;
let frameLocation = null;
let prevFrame = null;
let prevRef = null;
Expand All @@ -43,10 +42,9 @@ export function detectReferer(win) {
}

if (frameLocation) {
encodedUrl = encodeURIComponent(frameLocation);
stack.push(encodedUrl);
stack.push(frameLocation);
if (!detectedRefererUrl) {
detectedRefererUrl = encodedUrl;
detectedRefererUrl = frameLocation;
}
} else if (i !== 0) {
prevFrame = levels[i - 1];
Expand All @@ -58,16 +56,14 @@ export function detectReferer(win) {
}

if (prevRef) {
encodedUrl = encodeURIComponent(prevRef);
stack.push(encodedUrl);
stack.push(prevRef);
if (!detectedRefererUrl) {
detectedRefererUrl = encodedUrl;
detectedRefererUrl = prevRef;
}
} else if (ancestor) {
encodedUrl = encodeURIComponent(ancestor);
stack.push(encodedUrl);
stack.push(ancestor);
if (!detectedRefererUrl) {
detectedRefererUrl = encodedUrl;
detectedRefererUrl = ancestor;
}
} else {
stack.push(defUrl);
Expand Down
10 changes: 5 additions & 5 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,13 @@ describe('AppNexusAdapter', function () {
const bidRequest = Object.assign({}, bidRequests[0])
const bidderRequest = {
refererInfo: {
referer: 'http%3A%2F%2Fexample.com%2Fpage.html',
referer: 'http://example.com/page.html',
reachedTop: true,
numIframes: 2,
stack: [
'http%3A%2F%2Fexample.com%2Fpage.html',
'http%3A%2F%2Fexample.com%2Fiframe1.html',
'http%3A%2F%2Fexample.com%2Fiframe2.html'
'http://example.com/page.html',
'http://example.com/iframe1.html',
'http://example.com/iframe2.html'
]
}
}
Expand All @@ -393,7 +393,7 @@ describe('AppNexusAdapter', function () {
rd_ref: 'http%3A%2F%2Fexample.com%2Fpage.html',
rd_top: true,
rd_ifs: 2,
rd_stk: bidderRequest.refererInfo.stack.join(',')
rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',')
});
});
})
Expand Down
14 changes: 7 additions & 7 deletions test/spec/refererDetection_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ describe('referer detection', () => {
const getRefererInfo = detectReferer(mockIframe2WinObject);
let result = getRefererInfo();
let expectedResult = {
referer: 'http%3A%2F%2Fexample.com%2Fpage.html',
referer: 'http://example.com/page.html',
reachedTop: true,
numIframes: 2,
stack: [
'http%3A%2F%2Fexample.com%2Fpage.html',
'http%3A%2F%2Fexample.com%2Fiframe1.html',
'http%3A%2F%2Fexample.com%2Fiframe2.html'
'http://example.com/page.html',
'http://example.com/iframe1.html',
'http://example.com/iframe2.html'
]
};
expect(result).to.deep.equal(expectedResult);
Expand All @@ -66,13 +66,13 @@ describe('referer detection', () => {
const getRefererInfo = detectReferer(mockIframe2WinObject);
let result = getRefererInfo();
let expectedResult = {
referer: 'http%3A%2F%2Faaa.com%2Fiframe1.html',
referer: 'http://aaa.com/iframe1.html',
reachedTop: false,
numIframes: 2,
stack: [
null,
'http%3A%2F%2Faaa.com%2Fiframe1.html',
'http%3A%2F%2Fbbb.com%2Fiframe2.html'
'http://aaa.com/iframe1.html',
'http://bbb.com/iframe2.html'
]
};
expect(result).to.deep.equal(expectedResult);
Expand Down

0 comments on commit 616d306

Please sign in to comment.