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

Fix string/section mismatch when decoding gpp string #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gilluminate
Copy link

@gilluminate gilluminate commented Feb 14, 2025

Closes #79

When the cmpapi.setSectionString() method is called it was not updating the segments to match the decoded string, causing the string and section data to be mismatched.

This change includes the segments update for when the encode() method subsequently runs, ensuring they continue to be in sync.

To validate this fix:

import { CmpApi, TcfEuV2 } from "@iabgpp/cmpapi";

...
cmpApi.setSectionString(TcfEuV2.NAME, "CQM0UsAQM0UsAGXABBENBdFgALAAAENAAAAAFyQAQFyAXJABAXIAAAAAAA");

cmpApi.fireSectionChange(TcfEuV2.NAME);

console.log(cmpApi.getGppString());
// correctly returns DBABMA~CQM0UsAQM0UsAGXABBENBdFgALAAAENAAAAAFyQAQFyAXJABAXIAAAAA

const sections = cmpApi.getObject();
console.log(sections[TcfEuV2.NAME].PurposeConsents);
// correctly returns [true, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]

NOTE: I also included a bit of helpful output during the build process to show what it's working on.

Copy link
Collaborator

@HeinzBaumann HeinzBaumann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decoded string and related section data do not match as of 3.1.3
3 participants