From 06f11685c4828fcb1e67183b6088130cd2208e9a Mon Sep 17 00:00:00 2001 From: Zenon Mousmoulas Date: Tue, 9 Apr 2024 12:00:47 +0300 Subject: [PATCH] Ensure CMCD query argument is replaced (#20) The query argument added by the CMCD connector is preserved in subsequent manifest/segment requests by THEOplayer, apparently leading to multiple CMCD arguments being accumulated, which is a problem as the URL grows indefinitely. Using URLSearchParams set method, rather than append, ensures that the first CMCD argument is updated (the rest are removed) or one is appended. Co-authored-by: Mattias Buelens <649348+MattiasBuelens@users.noreply.github.com> --- .changeset/slow-melons-mix.md | 5 +++++ .../QueryArgumentTransmissionModeStrategy.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/slow-melons-mix.md diff --git a/.changeset/slow-melons-mix.md b/.changeset/slow-melons-mix.md new file mode 100644 index 00000000..ec66bef3 --- /dev/null +++ b/.changeset/slow-melons-mix.md @@ -0,0 +1,5 @@ +--- +"@theoplayer/cmcd-connector-web": patch +--- + +Fixed an issue where multiple CMCD query arguments were being added to the request URL. diff --git a/cmcd/src/TransmissionModeStrategies/QueryArgumentTransmissionModeStrategy.ts b/cmcd/src/TransmissionModeStrategies/QueryArgumentTransmissionModeStrategy.ts index 3dd7113d..3498c210 100644 --- a/cmcd/src/TransmissionModeStrategies/QueryArgumentTransmissionModeStrategy.ts +++ b/cmcd/src/TransmissionModeStrategies/QueryArgumentTransmissionModeStrategy.ts @@ -19,7 +19,7 @@ export class QueryArgumentTransmissionModeStrategy implements TransmissionModeSt const url = new URL(request.url); const parameters = transformToQueryParameters(payload); if (parameters) { - url.searchParams.append('CMCD', parameters); + url.searchParams.set('CMCD', parameters); request.redirect({ ...request, url: url.href