From cfdf7632f29c557b9e1e1873ff2c898f6510f230 Mon Sep 17 00:00:00 2001 From: Tsachi Shlidor Date: Wed, 13 May 2026 13:31:01 +0300 Subject: [PATCH] fix: handle f_auto extensionless raw-URLs --- .../models/video-source/video-source.const.js | 2 +- .../models/video-source/video-source.js | 24 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/plugins/cloudinary/models/video-source/video-source.const.js b/src/plugins/cloudinary/models/video-source/video-source.const.js index d48a7416..850a7f3d 100644 --- a/src/plugins/cloudinary/models/video-source/video-source.const.js +++ b/src/plugins/cloudinary/models/video-source/video-source.const.js @@ -13,7 +13,7 @@ export const DEFAULT_VIDEO_PARAMS = { chapters: {} }; -const COMMON_VIDEO_EXTENSIONS = [ +export const COMMON_VIDEO_EXTENSIONS = [ '3g2', '3gp', 'avi', diff --git a/src/plugins/cloudinary/models/video-source/video-source.js b/src/plugins/cloudinary/models/video-source/video-source.js index 71ffd044..06559a27 100644 --- a/src/plugins/cloudinary/models/video-source/video-source.js +++ b/src/plugins/cloudinary/models/video-source/video-source.js @@ -7,6 +7,7 @@ import { ADAPTIVE_SOURCETYPES, DEFAULT_POSTER_PARAMS, DEFAULT_VIDEO_PARAMS, + COMMON_VIDEO_EXTENSIONS, VIDEO_SUFFIX_REMOVAL_PATTERN } from './video-source.const'; import { @@ -167,8 +168,7 @@ class VideoSource extends BaseSource { generateSources() { if (this.isRawUrl) { - const type = this.sourceTypes()[0] === 'auto' ? null : this.sourceTypes()[0]; - return [this.generateRawSource(this.publicId(), type)]; + return [this.generateRawSource(this.publicId(), this.sourceTypes()[0])]; } const srcs = this.sourceTypes().map(sourceType => { @@ -231,17 +231,21 @@ class VideoSource extends BaseSource { } generateRawSource(url, type) { - type = type || url.split('.').pop(); + // If type is not provided (default is 'auto'), determine it from the URL extension + if (!type || type === 'auto') { + const ext = url.split('.').pop().split(/[?#]/)[0].toLowerCase(); + type = COMMON_VIDEO_EXTENSIONS.includes(ext) ? ext : 'auto'; + } const isAdaptive = ADAPTIVE_SOURCETYPES.includes(type); - if (CONTAINER_MIME_TYPES[type]) { - type = CONTAINER_MIME_TYPES[type]; - } else { - type = type ? `video/${type}` : null; - } - - return { type, src: url, cldSrc: this, isAdaptive, withCredentials: this.withCredentials }; + return { + type: CONTAINER_MIME_TYPES[type] || `video/${type}`, + src: url, + cldSrc: this, + isAdaptive, + withCredentials: this.withCredentials + }; } info(value) {