Skip to content

Commit

Permalink
Merge pull request #3 from adform/SSP-933
Browse files Browse the repository at this point in the history
SSP-933 URL parameter fix for HB solution
  • Loading branch information
evercoinx committed May 19, 2016
2 parents 9d56cb3 + d882806 commit 8bac68b
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions src/adapters/adform.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ function AdformAdapter() {
var request = [];
var adxDomain;

var singleRequest = {},
singleParam,
singleParams = [
'url'
];

for (var i = 0, l = bids.length; i < l; i++) {
bid = bids[i];
adxDomain = bid.params.adxDomain || bid.adxDomain;
Expand All @@ -26,13 +32,27 @@ function AdformAdapter() {
request.unshift('//' + adxDomain + '/adx/?rp=4');
}

request = request.concat( formRequestUrl(bid.params) );
request.push(formRequestUrl(bid.params));

for (var j = 0, k = singleParams.length; j < k; j++) {
singleParam = singleParams[ j ];
if ( bid.params[ singleParam ] ) {
singleRequest[ singleParam ] = bid.params[ singleParam ];
}
}
}

if (noDomain) {
request.unshift('//adx.adform.net/adx/?rp=4');
}

for (var j = 0, k = singleParams.length; j < k; j++) {
singleParam = singleParams[ j ];
if ( singleRequest[ singleParam ] ) {
request.push( singleParam + '=' + encodeURIComponent( singleRequest[ singleParam ] ) );
}
}

pbjs[callbackName] = handleCallback(bids);
request.push('callback=pbjs.' + callbackName);

Expand All @@ -41,33 +61,20 @@ function AdformAdapter() {

function formRequestUrl(reqData) {
var key;
var url = [],
params = [];
var url = [];

var validProps = [
'mid', 'inv', 'pdom', 'mname', 'mkw', 'mkv', 'cat', 'bcat', 'bcatrt', 'adv', 'advt', 'cntr', 'cntrt', 'maxp',
'minp', 'sminp', 'w', 'h', 'pb', 'pos', 'cturl', 'iturl', 'cttype', 'hidedomain', 'cdims', 'test'
];

var validPropsWithURIEncode = [
'url'
];

for (var i = 0, l = validProps.length; i < l; i++) {
key = validProps[i];
if (reqData.hasOwnProperty(key)) {
if (reqData.hasOwnProperty(key))
url.push(key, '=', reqData[key], '&');
}
}
params.push( encode64(url.join('')) );

for (var i = 0, l = validPropsWithURIEncode.length; i < l; i++) {
key = validPropsWithURIEncode[i];
if (reqData.hasOwnProperty(key)) {
params.push( [key, '=', encodeURIComponent( reqData[key] )].join('') );
}
}
return params;
return encode64(url.join(''));
}

function handleCallback(bids) {
Expand Down

0 comments on commit 8bac68b

Please sign in to comment.