Skip to content

Commit

Permalink
Merge pull request #4 from dmdconnects/feature/PREB-1-additional-user…
Browse files Browse the repository at this point in the history
…id-params

feat(prebid):additional parameter[PREB-1]
  • Loading branch information
matthewfitz authored Apr 22, 2021
2 parents cea9fe9 + 9582756 commit 54c8909
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions modules/dmdIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ export const dmdIdSubmodule = {
* @returns {(Object|undefined)}
*/
decode(value) {
return value && typeof value['dmd-dgid'] === 'string'
? { 'dmdId': value['dmd-dgid'] }
return value && typeof value === 'string'
? { 'dmdId': value }
: undefined;
},

/**
* performs action to obtain id and return a value in the callback's response argument
* @function getId
* @param {SubmoduleConfig} [config]
* @param {ConsentData}
* @param {Object} cacheIdObj - existing id, if any consentData]
* @returns {IdResponse|undefined}
*/
getId(config) {
getId(config, consentData, cacheIdObj) {
try {
const configParams = (config && config.params) || {};
if (
Expand All @@ -44,6 +46,8 @@ export const dmdIdSubmodule = {
) {
utils.logError('dmd submodule requires an api_key.');
return;
} else {
return cacheIdObj;
}
} catch (e) {
utils.logError(`dmdIdSystem encountered an error`, e);
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/dmdIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ describe('Dmd ID System', function() {
});

it('should return undefined if invalid dmd-dgid passed into decode', function () {
expect(dmdIdSubmodule.decode({'dmd-dgid': 123})).to.be.undefined;
expect(dmdIdSubmodule.decode(123)).to.be.undefined;
});

it('should return dmdId if valid dmd-dgid passed into decode', function () {
let data = { 'dmdId': 'U12345' };
expect(dmdIdSubmodule.decode({'dmd-dgid': 'U12345'})).to.deep.equal(data);
expect(dmdIdSubmodule.decode('U12345')).to.deep.equal(data);
});
});

0 comments on commit 54c8909

Please sign in to comment.