Skip to content

Commit 87d46df

Browse files
committed
gppControl: accept flat section data
1 parent 62307a3 commit 87d46df

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

libraries/mspa/activityControls.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '../../src/activities/activities.js';
88
import {gppDataHandler} from '../../src/adapterManager.js';
99
import {logInfo} from '../../src/utils.js';
10+
import {isPlainObject} from "lodash/lang.js";
1011

1112
// default interpretation for MSPA consent(s):
1213
// https://docs.prebid.org/features/mspa-usnat.html
@@ -105,7 +106,7 @@ export function mspaRule(sids, getConsent, denies, applicableSids = () => gppDat
105106
}
106107

107108
function flatSection(subsections) {
108-
if (subsections == null) return subsections;
109+
if (!Array.isArray(subsections)) return subsections;
109110
return subsections.reduceRight((subsection, consent) => {
110111
return Object.assign(consent, subsection);
111112
}, {});

test/spec/libraries/mspa/activityControls_spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ describe('setupRules', () => {
229229
sinon.assert.calledWith(rules.mockActivity, {mock: 'consent'})
230230
});
231231

232+
it('should accept already flattened section data', () => {
233+
consent.parsedSections.mockApi = {flat: 'consent'};
234+
runSetup('mockApi', [1]);
235+
isAllowed('mockActivity', {});
236+
sinon.assert.calledWith(rules.mockActivity, {flat: 'consent'})
237+
})
238+
232239
it('should not choke when no consent data is available', () => {
233240
consent = null;
234241
runSetup('mockApi', [1]);

0 commit comments

Comments
 (0)