UNPKG

shaka-player

Version:
35 lines (28 loc) • 953 B
/*! @license * Copyright 2024 Streaming Video Technology Alliance * SPDX-License-Identifier: Apache-2.0 */ goog.provide('cml.cmcd.toCmcdUrl'); goog.require('cml.cmcd.Cmcd'); goog.require('cml.cmcd.CmcdEncodeOptions'); goog.require('cml.cmcd.encodeCmcd'); goog.require('cml.cmcd.percentEncode'); /** * Convert a CMCD object to a URL encoded string. * * Only letters, digits, `-`, `.`, `_`, and `~` stay unencoded, as in the * query examples of CTA-5004-B. * * @param {cml.cmcd.Cmcd} cmcd The CMCD object to convert. * @param {cml.cmcd.CmcdEncodeOptions=} options Options for encoding. * @return {string} The URL encoded CMCD data. * * @see {@link https://cta-wave.github.io/Resources/common-media-client-data--cta-5004-b.html#query-argument-definition} */ cml.cmcd.toCmcdUrl = function(cmcd, options) { if (!cmcd) { return ''; } const params = cml.cmcd.encodeCmcd(cmcd, options); return cml.cmcd.percentEncode(params); };