Append CMCD query args to a URL.
If the URL has a CMCD parameter, the new value replaces it in place. The other parameters and the fragment stay as they are. If the data has no keys to send, the function returns the URL unchanged.
CMCD
The URL to append to.
The CMCD object to append.
Optional
Options for encoding.
The URL with the CMCD query args appended.
const url = 'https://test.com'const data = { br: [1000],}equal(appendCmcdQuery(url, data), `${url}?CMCD=br%3D%281000%29%2Cv%3D2`)equal(appendCmcdQuery(`${url}?hello=world`, data), `${url}?hello=world&CMCD=br%3D%281000%29%2Cv%3D2`) Copy
const url = 'https://test.com'const data = { br: [1000],}equal(appendCmcdQuery(url, data), `${url}?CMCD=br%3D%281000%29%2Cv%3D2`)equal(appendCmcdQuery(`${url}?hello=world`, data), `${url}?hello=world&CMCD=br%3D%281000%29%2Cv%3D2`)
CTA-5004-B Query Argument Definition
Append CMCD query args to a URL.
If the URL has a
CMCDparameter, the new value replaces it in place. The other parameters and the fragment stay as they are. If the data has no keys to send, the function returns the URL unchanged.