Skip to content

Commit 9e6485a

Browse files
authored
fix: handle f_auto extensionless raw-URLs (#1048)
1 parent 3c5b783 commit 9e6485a

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const DEFAULT_VIDEO_PARAMS = {
1313
chapters: {}
1414
};
1515

16-
const COMMON_VIDEO_EXTENSIONS = [
16+
export const COMMON_VIDEO_EXTENSIONS = [
1717
'3g2',
1818
'3gp',
1919
'avi',

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ADAPTIVE_SOURCETYPES,
88
DEFAULT_POSTER_PARAMS,
99
DEFAULT_VIDEO_PARAMS,
10+
COMMON_VIDEO_EXTENSIONS,
1011
VIDEO_SUFFIX_REMOVAL_PATTERN
1112
} from './video-source.const';
1213
import {
@@ -167,8 +168,7 @@ class VideoSource extends BaseSource {
167168

168169
generateSources() {
169170
if (this.isRawUrl) {
170-
const type = this.sourceTypes()[0] === 'auto' ? null : this.sourceTypes()[0];
171-
return [this.generateRawSource(this.publicId(), type)];
171+
return [this.generateRawSource(this.publicId(), this.sourceTypes()[0])];
172172
}
173173

174174
const srcs = this.sourceTypes().map(sourceType => {
@@ -231,17 +231,21 @@ class VideoSource extends BaseSource {
231231
}
232232

233233
generateRawSource(url, type) {
234-
type = type || url.split('.').pop();
234+
// If type is not provided (default is 'auto'), determine it from the URL extension
235+
if (!type || type === 'auto') {
236+
const ext = url.split('.').pop().split(/[?#]/)[0].toLowerCase();
237+
type = COMMON_VIDEO_EXTENSIONS.includes(ext) ? ext : 'auto';
238+
}
235239

236240
const isAdaptive = ADAPTIVE_SOURCETYPES.includes(type);
237241

238-
if (CONTAINER_MIME_TYPES[type]) {
239-
type = CONTAINER_MIME_TYPES[type];
240-
} else {
241-
type = type ? `video/${type}` : null;
242-
}
243-
244-
return { type, src: url, cldSrc: this, isAdaptive, withCredentials: this.withCredentials };
242+
return {
243+
type: CONTAINER_MIME_TYPES[type] || `video/${type}`,
244+
src: url,
245+
cldSrc: this,
246+
isAdaptive,
247+
withCredentials: this.withCredentials
248+
};
245249
}
246250

247251
info(value) {

0 commit comments

Comments
 (0)