Skip to content

Commit

Permalink
PBjs Core (Targeting): bugfix for issue #7323 adding extra spaces (#7337
Browse files Browse the repository at this point in the history
)
  • Loading branch information
peczenyj authored Sep 9, 2021
1 parent 545d903 commit 5ac1dbf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/targeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export function newTargeting(auctionManager) {
* "div-gpt-ad-1460505748561-0": [{"hb_bidder": ["appnexusAst"]}]
* },
* {
* "div-gpt-ad-1460505748561-0": [{"hb_bidder_appnexusAs": ["appnexusAst"]}]
* "div-gpt-ad-1460505748561-0": [{"hb_bidder_appnexusAs": ["appnexusAst", "other"]}]
* }
* ]
* ```
Expand All @@ -346,7 +346,7 @@ export function newTargeting(auctionManager) {
* {
* "div-gpt-ad-1460505748561-0": {
* "hb_bidder": "appnexusAst",
* "hb_bidder_appnexusAs": "appnexusAst"
* "hb_bidder_appnexusAs": "appnexusAst,other"
* }
* }
* ```
Expand All @@ -360,7 +360,7 @@ export function newTargeting(auctionManager) {
[Object.keys(targeting)[0]]: targeting[Object.keys(targeting)[0]]
.map(target => {
return {
[Object.keys(target)[0]]: target[Object.keys(target)[0]].join(', ')
[Object.keys(target)[0]]: target[Object.keys(target)[0]].join(',')
};
}).reduce((p, c) => Object.assign(c, p), {})
};
Expand Down Expand Up @@ -634,7 +634,7 @@ export function newTargeting(auctionManager) {

return Object.keys(aut)
.map(function(key) {
if (utils.isStr(aut[key])) aut[key] = aut[key].split(',');
if (utils.isStr(aut[key])) aut[key] = aut[key].split(',').map(s => s.trim());
if (!utils.isArray(aut[key])) aut[key] = [ aut[key] ];
return { [key]: aut[key] };
});
Expand Down
8 changes: 4 additions & 4 deletions test/spec/unit/core/targeting_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ describe('targeting tests', function () {
['string', '2.3', '2.3'],
['number', 2.3, '2.3'],
['boolean', true, 'true'],
['string-separated', '2.3,4.5', '2.3, 4.5'],
['array-of-string', ['2.3', '4.5'], '2.3, 4.5'],
['array-of-number', [2.3, 4.5], '2.3, 4.5'],
['array-of-boolean', [true, false], 'true, false']
['string-separated', '2.3, 4.5', '2.3,4.5'],
['array-of-string', ['2.3', '4.5'], '2.3,4.5'],
['array-of-number', [2.3, 4.5], '2.3,4.5'],
['array-of-boolean', [true, false], 'true,false']
];
pairs.forEach(([type, value, result]) => {
it(`accepts ${type}`, function() {
Expand Down

0 comments on commit 5ac1dbf

Please sign in to comment.