diff --git a/libraries/appnexusKeywords/anKeywords.js b/libraries/appnexusKeywords/anKeywords.js index e4c770a0b18..271a09edba6 100644 --- a/libraries/appnexusKeywords/anKeywords.js +++ b/libraries/appnexusKeywords/anKeywords.js @@ -60,24 +60,10 @@ export function convertKeywordStringToANMap(keyStr) { function convertKeywordsToANMap(kwarray) { const result = {}; kwarray.forEach(kw => { - // if = exists, then split - if (kw.indexOf('=') !== -1) { - let kwPair = kw.split('='); - let key = kwPair[0]; - let val = kwPair[1]; - - // then check for existing key in result > if so add value to the array > if not, add new key and create value array - if (result.hasOwnProperty(key)) { - result[key].push(val); - } else { - result[key] = [val]; - } - } else { - if (!result.hasOwnProperty(kw)) { - result[kw] = []; - } + if (!result.hasOwnProperty(kw)) { + result[kw] = []; } - }) + }); return result; } diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 0660f4f4b10..047fa7115e4 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -36,7 +36,6 @@ import {hasPurpose1Consent} from '../src/utils/gpdr.js'; import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; import {APPNEXUS_CATEGORY_MAPPING} from '../libraries/categoryTranslationMapping/index.js'; import { - convertKeywordStringToANMap, getANKewyordParamFromMaps, getANKeywordParam, transformBidderParamKeywords @@ -783,7 +782,7 @@ function bidToTag(bid) { tag.external_imp_id = bid.params.external_imp_id; } - const auKeywords = getANKewyordParamFromMaps(convertKeywordStringToANMap(deepAccess(bid, 'ortb2Imp.ext.data.keywords')), bid.params?.keywords); + const auKeywords = getANKewyordParamFromMaps(bid.params?.keywords); if (auKeywords.length > 0) { tag.keywords = auKeywords; } diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 7d351e03453..6b38dec0779 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -757,9 +757,13 @@ describe('AppNexusAdapter', function () { 'value': ['rock', 'pop'] }, { 'key': 'test' + }, { + key: 'tools=industrial', + }, { + key: 'tools=home', }, { 'key': 'tools', - 'value': ['power', 'industrial', 'home'] + 'value': ['power'] }, { 'key': 'power tools' }, { @@ -767,16 +771,13 @@ describe('AppNexusAdapter', function () { }, { 'key': 'video' }, { - 'key': 'source', - 'value': ['streaming'] + 'key': 'source=streaming', }, { 'key': 'renting' }, { - 'key': 'app', - 'value': ['iphone 11'] + 'key': 'app=iphone 11', }, { - 'key': 'appcontent', - 'value': ['home repair'] + 'key': 'appcontent=home repair', }, { 'key': 'dyi' }]); @@ -908,94 +909,6 @@ describe('AppNexusAdapter', function () { ]) }); - it('should convert adUnit ortb2 keywords (when there are no bid param keywords) to proper form and attaches to request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - ortb2Imp: { - ext: { - data: { - keywords: 'ortb2=yes,ortb2test, multiValMixed=4, singleValNum=456' - } - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expectKeywords(payload.tags[0].keywords, [{ - 'key': 'ortb2', - 'value': ['yes'] - }, { - 'key': 'ortb2test' - }, { - 'key': 'multiValMixed', - 'value': ['4'] - }, { - 'key': 'singleValNum', - 'value': ['456'] - }]); - }); - - it('should convert keyword params and adUnit ortb2 keywords to proper form and attaches to request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - placementId: '10433394', - keywords: { - single: 'val', - singleArr: ['val'], - singleArrNum: [5], - multiValMixed: ['value1', 2, 'value3'], - singleValNum: 123, - emptyStr: '', - emptyArr: [''], - badValue: { 'foo': 'bar' } // should be dropped - } - }, - ortb2Imp: { - ext: { - data: { - keywords: 'ortb2=yes,ortb2test, multiValMixed=4, singleValNum=456' - } - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expectKeywords(payload.tags[0].keywords, [{ - 'key': 'single', - 'value': ['val'] - }, { - 'key': 'singleArr', - 'value': ['val'] - }, { - 'key': 'singleArrNum', - 'value': ['5'] - }, { - 'key': 'multiValMixed', - 'value': ['value1', '2', 'value3', '4'] - }, { - 'key': 'singleValNum', - 'value': ['123', '456'] - }, { - 'key': 'emptyStr' - }, { - 'key': 'emptyArr' - }, { - 'key': 'ortb2', - 'value': ['yes'] - }, { - 'key': 'ortb2test' - }]); - }); - it('should add payment rules to the request', function () { let bidRequest = Object.assign({}, bidRequests[0],