Skip to content

Function: appendCmcdQuery() ​

ts
function appendCmcdQuery(
   url, 
   cmcd, 
   options?
): string;

Defined in: appendCmcdQuery.ts:26

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.

Parameters ​

url ​

string

The URL to append to.

cmcd ​

Cmcd

The CMCD object to append.

options? ​

CmcdEncodeOptions

Options for encoding.

Returns ​

string

The URL with the CMCD query args appended.

Example ​

ts
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`,
)

See ​

CTA-5004-B Query Argument Definition

A Streaming Video Technology Alliance project.