CML
    Preparing search index...

    Function appendCmcdQuery

    • 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.

      • Optionaloptions: CmcdEncodeOptions

        Options for encoding.

      Returns string

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