Skip to content

Commit bca444f

Browse files
authored
fix: analytics query-string for better browser cache (#1024)
1 parent fa56287 commit bca444f

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

src/plugins/cloudinary/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class CloudinaryContext {
207207
{ hasUserPosterOptions: hasUserPosterOptions || null }
208208
);
209209

210-
options.queryParams = Object.assign(options.queryParams || {}, options.allowUsageReport ? { _s: `vp-${VERSION}` } : {});
210+
options.queryParams = Object.assign(options.queryParams || {}, options.allowUsageReport ? { _s: 'vp' } : {});
211211

212212
if (options.sourceTypes.indexOf('audio') > -1) {
213213
builtSrc = new AudioSource(publicId, options);

src/plugins/cloudinary/models/video-source/video-source.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ class VideoSource extends BaseSource {
130130

131131
options.cloudinaryConfig = options.cloudinaryConfig || this.cloudinaryConfig();
132132
options.resource_type = this.resourceType() || options.resource_type;
133-
options.queryParams = this.queryParams();
133+
134+
if (!isRawUrl(publicId)) {
135+
options.queryParams = this.queryParams();
136+
}
134137

135138
if (publicId === true) {
136139
const urlPrefix = getCloudinaryUrlPrefix(options.cloudinaryConfig);

src/utils/fetch-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const fetchConfig = async (options) => {
2525

2626
const cloudinaryConfig = getCloudinaryConfigFromOptions(options);
2727
const urlPrefix = getCloudinaryUrlPrefix(cloudinaryConfig) + '/_applet_/video_service';
28-
const queryParams = allowUsageReport ? { _s: `vp-${VERSION}` } : null;
28+
const queryParams = allowUsageReport ? { _s: 'vp' } : null;
2929

3030
let configUrl;
3131
if (profile) {

test/unit/videoSource.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,24 @@ describe('test hasCodec method', () => {
571571
expect(posterUrl).toContain('/video/upload/');
572572
});
573573

574+
it('does not append source queryParams to raw absolute poster URLs', () => {
575+
const posterHref = 'https://cdn.example.com/assets/poster.jpg';
576+
const source = new VideoSource('sea_turtle', {
577+
cloudinaryConfig: cld,
578+
queryParams: { _s: 'vp' },
579+
poster: posterHref
580+
});
581+
expect(source.poster().url()).toBe(posterHref);
582+
});
583+
584+
it('appends stable _s to Cloudinary-built poster URLs', () => {
585+
const source = new VideoSource('sea_turtle', {
586+
cloudinaryConfig: cld,
587+
queryParams: { _s: 'vp' }
588+
});
589+
expect(source.poster().url()).toContain('_s=vp');
590+
});
591+
574592
it('should use configured resourceType for seek thumbnails', () => {
575593
const source = new VideoSource('sample', {
576594
cloudinaryConfig: cld,

0 commit comments

Comments
 (0)