From 5ac1dbff44d7c557e5cedb459e0c84a3741e7b93 Mon Sep 17 00:00:00 2001 From: Tiago Peczenyj Date: Thu, 9 Sep 2021 19:01:16 +0200 Subject: [PATCH] PBjs Core (Targeting): bugfix for issue #7323 adding extra spaces (#7337) --- src/targeting.js | 8 ++++---- test/spec/unit/core/targeting_spec.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/targeting.js b/src/targeting.js index 4bbed7bb758..96692376d82 100644 --- a/src/targeting.js +++ b/src/targeting.js @@ -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"]}] * } * ] * ``` @@ -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" * } * } * ``` @@ -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), {}) }; @@ -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] }; }); diff --git a/test/spec/unit/core/targeting_spec.js b/test/spec/unit/core/targeting_spec.js index f83bd2f6635..1064d7c0f7d 100644 --- a/test/spec/unit/core/targeting_spec.js +++ b/test/spec/unit/core/targeting_spec.js @@ -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() {