From f384ca470540bd37974fe634361d57d505607ff6 Mon Sep 17 00:00:00 2001 From: Rok Susnik Date: Wed, 28 Apr 2021 11:01:21 +0200 Subject: [PATCH] fix outbrain usersync query params --- modules/outbrainBidAdapter.js | 10 +++++---- test/spec/modules/outbrainBidAdapter_spec.js | 22 ++++++-------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/modules/outbrainBidAdapter.js b/modules/outbrainBidAdapter.js index 304cdf2088c..c0af09c2b50 100644 --- a/modules/outbrainBidAdapter.js +++ b/modules/outbrainBidAdapter.js @@ -147,18 +147,20 @@ export const spec = { getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => { const syncs = []; let syncUrl = config.getConfig('outbrain.usersyncUrl'); + + let query = []; if (syncOptions.pixelEnabled && syncUrl) { if (gdprConsent) { - syncUrl += '&gdpr=' + (gdprConsent.gdprApplies & 1); - syncUrl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''); + query.push('gdpr=' + (gdprConsent.gdprApplies & 1)); + query.push('gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || '')); } if (uspConsent) { - syncUrl += '&us_privacy=' + encodeURIComponent(uspConsent); + query.push('us_privacy=' + encodeURIComponent(uspConsent)); } syncs.push({ type: 'image', - url: syncUrl + url: syncUrl + (query.length ? '?' + query.join('&') : '') }); } return syncs; diff --git a/test/spec/modules/outbrainBidAdapter_spec.js b/test/spec/modules/outbrainBidAdapter_spec.js index 9671adf826e..4bdd657f419 100644 --- a/test/spec/modules/outbrainBidAdapter_spec.js +++ b/test/spec/modules/outbrainBidAdapter_spec.js @@ -493,19 +493,9 @@ describe('Outbrain Adapter', function () { config.resetConfig() }) - it('should return user sync if pixel enabled', function () { - const ret = spec.getUserSyncs({pixelEnabled: true}) - expect(ret).to.deep.equal([{type: 'image', url: 'https://usersync-url.com'}]) - }) it('should return user sync if pixel enabled with outbrain config', function () { - config.resetConfig() - config.setConfig({ - outbrain: { - usersyncUrl: 'https://usersync-url.com', - } - }) const ret = spec.getUserSyncs({pixelEnabled: true}) - expect(ret).to.deep.equal([{type: 'image', url: 'https://usersync-url.com'}]) + expect(ret).to.deep.equal([{type: 'image', url: usersyncUrl}]) }) it('should not return user sync if pixel disabled', function () { @@ -521,25 +511,25 @@ describe('Outbrain Adapter', function () { it('should pass GDPR consent', function() { expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, undefined)).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&gdpr=1&gdpr_consent=foo` + type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=foo` }]); expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: false, consentString: 'foo'}, undefined)).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&gdpr=0&gdpr_consent=foo` + type: 'image', url: `${usersyncUrl}?gdpr=0&gdpr_consent=foo` }]); expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: undefined}, undefined)).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&gdpr=1&gdpr_consent=` + type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=` }]); }); it('should pass US consent', function() { expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined, '1NYN')).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&us_privacy=1NYN` + type: 'image', url: `${usersyncUrl}?us_privacy=1NYN` }]); }); it('should pass GDPR and US consent', function() { expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, '1NYN')).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&gdpr=1&gdpr_consent=foo&us_privacy=1NYN` + type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=foo&us_privacy=1NYN` }]); }); })