Skip to content

Commit fd85a1c

Browse files
committed
fix: cloudinary config is always undefined
1 parent 91951d6 commit fd85a1c

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/utils/fetch-config.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import pick from 'lodash/pick';
12
import { defaultProfiles } from 'cloudinary-video-player-profiles';
23
import { isRawUrl, getCloudinaryUrlPrefix } from '../plugins/cloudinary/url-helpers';
4+
import { CLOUDINARY_CONFIG_PARAM } from '../video-player.const';
35
import { utf8ToBase64 } from '../utils/utf8Base64';
46
import { appendQueryParams } from './querystring';
7+
import { convertKeysToSnakeCase } from './object';
58

69
const isDefaultProfile = (profileName) => !!defaultProfiles.find(({ name }) => profileName === name);
710

@@ -15,13 +18,23 @@ const getDefaultProfileConfig = (profileName) => {
1518
return profile.config;
1619
};
1720

21+
const getCloudinaryConfigFromOptions = (options) => {
22+
if (options.cloudinaryConfig) {
23+
return options.cloudinaryConfig;
24+
}
25+
26+
const fromFlat = pick(convertKeysToSnakeCase(options), CLOUDINARY_CONFIG_PARAM);
27+
return Object.assign({}, fromFlat, options.cloudinary || {});
28+
};
29+
1830
const fetchConfig = async (options) => {
19-
const { profile, publicId, cloudinaryConfig, type = 'upload', videoConfig, allowUsageReport = true } = options;
31+
const { profile, publicId, type = 'upload', videoConfig, allowUsageReport = true } = options;
2032

2133
if (profile && isDefaultProfile(profile)) {
2234
return getDefaultProfileConfig(profile);
2335
}
2436

37+
const cloudinaryConfig = getCloudinaryConfigFromOptions(options);
2538
const urlPrefix = getCloudinaryUrlPrefix(cloudinaryConfig) + '/_applet_/video_service';
2639
const queryParams = allowUsageReport ? { _s: `vp-${VERSION}` } : null;
2740

0 commit comments

Comments
 (0)