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 double encoded targeting string for Yieldlab adapter #5522

Merged
merged 2 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion modules/yieldlabBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const spec = {
utils._each(validBidRequests, function (bid) {
adslotIds.push(bid.params.adslotId)
if (bid.params.targeting) {
query.t = createQueryString(bid.params.targeting)
query.t = createTargetingString(bid.params.targeting)
}
if (bid.userIdAsEids && Array.isArray(bid.userIdAsEids)) {
query.ids = createUserIdString(bid.userIdAsEids)
Expand Down Expand Up @@ -198,6 +198,23 @@ function createQueryString (obj) {
return str.join('&')
}

/**
* Creates an unencoded targeting string out of an object with key-values
* @param {Object} obj
* @returns {String}
*/
function createTargetingString (obj) {
let str = []
for (var p in obj) {
if (obj.hasOwnProperty(p)) {
let key = p
let val = obj[p]
str.push(key + '=' + val)
}
}
return str.join('&')
}

/**
* Handles an outstream response after the library is loaded
* @param {Object} bid
Expand Down
7 changes: 4 additions & 3 deletions test/spec/modules/yieldlabBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const REQUEST = {
'adSize': '728x90',
'targeting': {
'key1': 'value1',
'key2': 'value2'
'key2': 'value2',
'notDoubleEncoded': 'value3,value4'
},
'customParams': {
'extraParam': true,
Expand Down Expand Up @@ -84,8 +85,8 @@ describe('yieldlabBidAdapter', function () {
expect(request.validBidRequests).to.eql([REQUEST])
})

it('passes targeting to bid request', function () {
expect(request.url).to.include('t=key1%3Dvalue1%26key2%3Dvalue2')
it('passes single-encoded targeting to bid request', function () {
expect(request.url).to.include('t=key1%3Dvalue1%26key2%3Dvalue2%26notDoubleEncoded%3Dvalue3%2Cvalue4')
})

it('passes userids to bid request', function () {
Expand Down