Skip to content

Commit

Permalink
userId: fix bug where pubProvidedId UIDs are duplicated (#10795)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi authored Dec 7, 2023
1 parent 8ab882f commit c6a13ca
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/userId/eids.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {deepAccess, isFn, isPlainObject, isStr} from '../../src/utils.js';
import {deepAccess, deepClone, isFn, isPlainObject, isStr} from '../../src/utils.js';

export const EID_CONFIG = new Map();

Expand Down Expand Up @@ -45,7 +45,7 @@ export function createEidsArray(bidRequestUserId) {

Object.entries(bidRequestUserId).forEach(([name, values]) => {
values = Array.isArray(values) ? values : [values];
const eids = name === 'pubProvidedId' ? values : values.map(value => createEidObject(value, name));
const eids = name === 'pubProvidedId' ? deepClone(values) : values.map(value => createEidObject(value, name));
eids.filter(eid => eid != null).forEach(collect);
})
return Object.values(allEids);
Expand Down
20 changes: 19 additions & 1 deletion test/spec/modules/userId_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,25 @@ describe('User ID', function () {
]
}
])
})
});

it('when merging with pubCommonId, should not alter its eids', () => {
const uid = {
pubProvidedId: [
{
source: 'mock1Source',
uids: [
{id: 'uid2'}
]
}
],
mockId1: 'uid1',
};
const eids = createEidsArray(uid);
expect(eids).to.have.length(1);
expect(eids[0].uids.map(u => u.id)).to.have.members(['uid1', 'uid2']);
expect(uid.pubProvidedId[0].uids).to.eql([{id: 'uid2'}]);
});
})

it('pbjs.getUserIds', function (done) {
Expand Down

0 comments on commit c6a13ca

Please sign in to comment.