Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issue #4950 #4951

Closed
wants to merge 54 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5a2b8c2
Fixing issue #4950
leonardlabat Mar 9, 2020
844f52b
Added test case & removed duplicated utils function
leonardlabat Mar 9, 2020
a088d66
update audigent tests to fix larger test suite issue (#4952)
jsnellbaker Mar 9, 2020
60f66c9
enable no-console eslint rule for project (#4802)
jsnellbaker Mar 10, 2020
5d4c823
Fix failing code-coverage command (#4892)
Fawke Mar 10, 2020
9325d22
Add 7xbid adapter to compatible with prebid 3.0 (#4908)
7XBID00 Mar 10, 2020
fc8ebec
add import extensions (#4959)
robertrmartinez Mar 10, 2020
f5b0e4e
removing the log (#4960)
robertrmartinez Mar 10, 2020
bb015bd
adding user-id support in medianet adapter (#4925)
vedantseta Mar 10, 2020
79a5f46
added option to url parser to ignore decoding entire url (#4938)
robertrmartinez Mar 10, 2020
8c84e01
assert string returned not that we break things (#4962)
robertrmartinez Mar 10, 2020
1b62b0b
IX Adapter - Increase banner TTL to 300s (#4957)
ix-prebid-support Mar 11, 2020
6113cd9
Lifestreet adapter 3.0 (#4927)
probably-kira Mar 11, 2020
6005a29
Module - Size Mapping V2 (#4690)
Fawke Mar 11, 2020
ef57d43
update logic in adpod module for playersize (#4953)
jsnellbaker Mar 11, 2020
0b75199
add mediaforce bid adapter (#4933)
ksanksana Mar 11, 2020
efae8f8
Eids liveintent ext fix (#4944)
pm-harshad-mane Mar 11, 2020
4af14c9
3.11.0 release
mkendall07 Mar 11, 2020
364b385
3.12.0-pre
mkendall07 Mar 11, 2020
f890eb8
add UNICORN bid adapter (#4917)
ctylim Mar 12, 2020
0ccf807
Added support for merging arrays and some test cases
leonardlabat Mar 12, 2020
703b898
Submitting Clicktripz bid adapter (#4929)
apmitchell Mar 12, 2020
00c4cb0
PrebidServerbidAdapter to use userIdAsEids to set eids in request (#4…
pm-harshad-mane Mar 13, 2020
2db8ecf
Conversant bid adapter to use userIdAsEids (#4967)
pm-harshad-mane Mar 16, 2020
5df9c8f
add support for TCF2 (#4911)
jsnellbaker Mar 17, 2020
1034f27
New e-volution tech bid adapter (#4934)
e-volution-tech Mar 17, 2020
a95f911
Add enforcement for deviceAccess (#4913)
Mar 17, 2020
d1f0ea1
Fix failing circle-ci build job. (#4840)
Fawke Mar 17, 2020
aa36b5a
Add alias Select Media into Adtelligent (#4985)
GeneGenie Mar 17, 2020
320e3a0
NoBid version 1.2.4 (#4971)
redaguermas Mar 17, 2020
02069e4
Prebid 3.12.0 Release
Mar 17, 2020
0de00fe
Increment pre version
Mar 17, 2020
9fc9579
Liveintent liveconnect module (#4803)
melgenek Mar 18, 2020
cbdea4a
Vidazoo adapter: update maintainer email (#5006)
uditalias Mar 20, 2020
dfcbd25
Add coppa support for Quantcast adapter (#5012)
weilingxi-qc Mar 20, 2020
9523787
Add Valueimpression Bid Adapter (#4974)
thuyhq Mar 21, 2020
07cf06f
appnexus adapter : include hb_source in request to server (#4964)
sumit116 Mar 24, 2020
fecfc2b
Index Exchange: Registering user syncs (#5005)
ix-prebid-support Mar 24, 2020
f0bc358
update consent manager to support a new config prop: defaultGdprScope…
Mar 24, 2020
498b771
freewheel add property vastXml to bidResponse (#5015)
xwang202 Mar 24, 2020
da6bb01
Added Adnuntius Bid Adapter (#4896)
mikael-lundin Mar 24, 2020
b24156c
deal tier fix (#5028)
jaiminpanchal27 Mar 24, 2020
a1083ff
PubMatic bid adapter to support NetId User Module (#5009)
pm-harshad-mane Mar 25, 2020
adda4e1
Undertone add parameters to request (#4995)
AnnaPerion Mar 25, 2020
e4ea90f
PulsePoint bid adapter: Multi-size support (#4988)
anand-venkatraman Mar 25, 2020
18b4009
VIS.X: use schain & userId modules (#5004)
mk0x9 Mar 25, 2020
811dd44
ADFINITY adapter gdpr support (#4955)
adfinity-prebid Mar 25, 2020
9268e98
Prebid 3.13.0 Release
Mar 25, 2020
efa289e
Increment pre version
Mar 25, 2020
7c45626
Media.net : adds Analytics Adapter (#5016)
vedantseta Mar 26, 2020
d7424a5
Fixing issue #4950
leonardlabat Mar 9, 2020
6cb6fd1
Added test case & removed duplicated utils function
leonardlabat Mar 9, 2020
b128bc2
Added support for merging arrays and some test cases
leonardlabat Mar 12, 2020
3a37ebd
Merge branch 'issue_4950' of github.com:criteo-forks/Prebid.js into i…
leonardlabat Mar 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import find from 'core-js/library/fn/array/find.js';
import includes from 'core-js/library/fn/array/includes.js';
import Set from 'core-js/library/fn/set.js';
import { parseQS } from './url.js';
import { mergeDeep } from './utils.js';

const from = require('core-js/library/fn/array/from.js');
const utils = require('./utils.js');
Expand Down Expand Up @@ -243,7 +244,7 @@ export function newConfig() {
memo[topic] = currBidderConfig[topic];
} else {
if (utils.isPlainObject(currBidderConfig[topic])) {
memo[topic] = Object.assign({}, config[topic], currBidderConfig[topic]);
memo[topic] = mergeDeep({}, config[topic], currBidderConfig[topic]);
} else {
memo[topic] = currBidderConfig[topic];
}
Expand Down
24 changes: 24 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1266,3 +1266,27 @@ export function compareOn(property) {
return 0;
}
}

export function mergeDeep(target, ...sources) {
if (!sources.length) return target;
const source = sources.shift();

if (isPlainObject(target) && isPlainObject(source)) {
for (const key in source) {
if (isPlainObject(source[key])) {
if (!target[key]) Object.assign(target, { [key]: {} });
mergeDeep(target[key], source[key]);
} else if (isArray(source[key])) {
if (!target[key]) {
Object.assign(target, { [key]: source[key] });
} else if (isArray(target[key])) {
target[key] = target[key].concat(source[key]);
}
} else {
Object.assign(target, { [key]: source[key] });
}
}
}

return mergeDeep(target, ...sources);
}
8 changes: 4 additions & 4 deletions test/spec/unit/core/adapterManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('adapterManager tests', function () {
buildRequests: {
data: 1
},
test1: { speedy: true },
test1: { speedy: true, fun: { test: true } },
interpretResponse: 'baseInterpret',
afterInterpretResponse: 'anotherBaseInterpret'
});
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('adapterManager tests', function () {
data: 1,
test: 2
},
{ fun: { safe: true, cheap: false }, speedy: true },
{ fun: { safe: true, cheap: false, test: true }, speedy: true },
{ amazing: true },
'appnexusInterpret',
'anotherBaseInterpret'
Expand All @@ -221,14 +221,14 @@ describe('adapterManager tests', function () {
{
data: 1
},
{ speedy: true },
{ fun: { test: true }, speedy: true },
undefined,
'baseInterpret',
'anotherBaseInterpret'
],
'rubicon': [
'rubiconBuild',
{ speedy: true },
{ fun: { test: true }, speedy: true },
{ amazing: true },
null,
'anotherBaseInterpret'
Expand Down
97 changes: 97 additions & 0 deletions test/spec/utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -922,4 +922,101 @@ describe('Utils', function () {
});
});
});

describe('mergeDeep', function() {
it('properly merge objects that share same property names', function() {
const object1 = {
propA: {
subPropA: 'abc'
}
};
const object2 = {
propA: {
subPropB: 'def'
}
};

const resultWithoutMergeDeep = Object.assign({}, object1, object2);
expect(resultWithoutMergeDeep).to.deep.equal({
propA: {
subPropB: 'def'
}
});

const resultWithMergeDeep = utils.mergeDeep({}, object1, object2);
expect(resultWithMergeDeep).to.deep.equal({
propA: {
subPropA: 'abc',
subPropB: 'def'
}
});
});

it('properly merge objects that have different depths', function() {
const object1 = {
depth0_A: {
depth1_A: {
depth2_A: 123
}
}
};
const object2 = {
depth0_A: {
depth1_A: {
depth2_B: {
depth3_A: {
depth4_A: 'def'
}
}
},
depth1_B: 'abc'
}
};
const object3 = {
depth0_B: 456
};

const result = utils.mergeDeep({}, object1, object2, object3);
expect(result).to.deep.equal({
depth0_A: {
depth1_A: {
depth2_A: 123,
depth2_B: {
depth3_A: {
depth4_A: 'def'
}
}
},
depth1_B: 'abc'
},
depth0_B: 456
});
});

it('properly merge objects with various property types', function() {
const object1 = {
depth0_A: {
depth1_A: ['a', 'b', 'c'],
depth1_B: 'abc',
depth1_C: 123
}
};
const object2 = {
depth0_A: {
depth1_A: ['d', 'e', 'f'],
depth1_D: true,
}
};

const result = utils.mergeDeep({}, object1, object2);
expect(result).to.deep.equal({
depth0_A: {
depth1_A: ['a', 'b', 'c', 'd', 'e', 'f'],
depth1_B: 'abc',
depth1_C: 123,
depth1_D: true,
}
});
});
});
leonardlabat marked this conversation as resolved.
Show resolved Hide resolved
});