From 3f886882f5ce936f6ea69dfb03d77dddfea8a010 Mon Sep 17 00:00:00 2001 From: Tiago Peczenyj Date: Tue, 24 Aug 2021 12:15:13 +0200 Subject: [PATCH 1/3] fix issue #7323 --- src/targeting.js | 6 +++--- test/spec/unit/core/targeting_spec.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/targeting.js b/src/targeting.js index 4bbed7bb758..b8901f60aee 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), {}) }; diff --git a/test/spec/unit/core/targeting_spec.js b/test/spec/unit/core/targeting_spec.js index f83bd2f6635..3f5275d5d6f 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() { From d5372ba12936238a43c6eedbdb20b373ec7ca73d Mon Sep 17 00:00:00 2001 From: Tiago Peczenyj Date: Mon, 30 Aug 2021 11:36:41 +0200 Subject: [PATCH 2/3] update unit test --- test/spec/unit/core/targeting_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/unit/core/targeting_spec.js b/test/spec/unit/core/targeting_spec.js index 3f5275d5d6f..a58289ec55d 100644 --- a/test/spec/unit/core/targeting_spec.js +++ b/test/spec/unit/core/targeting_spec.js @@ -309,7 +309,7 @@ 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'], + ['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'] From dddcc23b1954e2012b3ccd1f8a51ae444d966a18 Mon Sep 17 00:00:00 2001 From: Tiago Peczenyj Date: Mon, 30 Aug 2021 14:00:51 +0200 Subject: [PATCH 3/3] add trim after split by comma --- src/targeting.js | 2 +- test/spec/unit/core/targeting_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/targeting.js b/src/targeting.js index b8901f60aee..96692376d82 100644 --- a/src/targeting.js +++ b/src/targeting.js @@ -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 a58289ec55d..1064d7c0f7d 100644 --- a/test/spec/unit/core/targeting_spec.js +++ b/test/spec/unit/core/targeting_spec.js @@ -309,7 +309,7 @@ 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'], + ['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']