From 36e3d4e9f667b07fd9955b87ac2e8cf28795a8cb Mon Sep 17 00:00:00 2001 From: Tsachi Shlidor Date: Mon, 6 Apr 2026 13:44:43 +0300 Subject: [PATCH] fix: analytics query-string for better browser cache --- src/plugins/cloudinary/index.js | 2 +- .../models/video-source/video-source.js | 5 ++++- src/utils/fetch-config.js | 2 +- test/unit/videoSource.test.js | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/plugins/cloudinary/index.js b/src/plugins/cloudinary/index.js index eb3e4df5..975088e5 100644 --- a/src/plugins/cloudinary/index.js +++ b/src/plugins/cloudinary/index.js @@ -207,7 +207,7 @@ class CloudinaryContext { { hasUserPosterOptions: hasUserPosterOptions || null } ); - options.queryParams = Object.assign(options.queryParams || {}, options.allowUsageReport ? { _s: `vp-${VERSION}` } : {}); + options.queryParams = Object.assign(options.queryParams || {}, options.allowUsageReport ? { _s: 'vp' } : {}); if (options.sourceTypes.indexOf('audio') > -1) { builtSrc = new AudioSource(publicId, options); diff --git a/src/plugins/cloudinary/models/video-source/video-source.js b/src/plugins/cloudinary/models/video-source/video-source.js index 47dc51c0..71ffd044 100644 --- a/src/plugins/cloudinary/models/video-source/video-source.js +++ b/src/plugins/cloudinary/models/video-source/video-source.js @@ -130,7 +130,10 @@ class VideoSource extends BaseSource { options.cloudinaryConfig = options.cloudinaryConfig || this.cloudinaryConfig(); options.resource_type = this.resourceType() || options.resource_type; - options.queryParams = this.queryParams(); + + if (!isRawUrl(publicId)) { + options.queryParams = this.queryParams(); + } if (publicId === true) { const urlPrefix = getCloudinaryUrlPrefix(options.cloudinaryConfig); diff --git a/src/utils/fetch-config.js b/src/utils/fetch-config.js index 8de092d7..c0b99b49 100644 --- a/src/utils/fetch-config.js +++ b/src/utils/fetch-config.js @@ -36,7 +36,7 @@ const fetchConfig = async (options) => { const cloudinaryConfig = getCloudinaryConfigFromOptions(options); const urlPrefix = getCloudinaryUrlPrefix(cloudinaryConfig) + '/_applet_/video_service'; - const queryParams = allowUsageReport ? { _s: `vp-${VERSION}` } : null; + const queryParams = allowUsageReport ? { _s: 'vp' } : null; let configUrl; if (profile) { diff --git a/test/unit/videoSource.test.js b/test/unit/videoSource.test.js index 2e4638f9..c9da6fe4 100644 --- a/test/unit/videoSource.test.js +++ b/test/unit/videoSource.test.js @@ -571,6 +571,24 @@ describe('test hasCodec method', () => { expect(posterUrl).toContain('/video/upload/'); }); + it('does not append source queryParams to raw absolute poster URLs', () => { + const posterHref = 'https://cdn.example.com/assets/poster.jpg'; + const source = new VideoSource('sea_turtle', { + cloudinaryConfig: cld, + queryParams: { _s: 'vp' }, + poster: posterHref + }); + expect(source.poster().url()).toBe(posterHref); + }); + + it('appends stable _s to Cloudinary-built poster URLs', () => { + const source = new VideoSource('sea_turtle', { + cloudinaryConfig: cld, + queryParams: { _s: 'vp' } + }); + expect(source.poster().url()).toContain('_s=vp'); + }); + it('should use configured resourceType for seek thumbnails', () => { const source = new VideoSource('sample', { cloudinaryConfig: cld,