Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const buildUrl = fileInfo => {
const { cdnUrl, name, isImage } = fileInfo;
let url =
isImage && settings.defaultOperations ? `${cdnUrl}-${settings.defaultOperations}` : cdnUrl;
const filenameDefined = !url.endsWith('/');
if (!filenameDefined && settings.autoFilename) {
url = url + name;
}
return url;
};
uploadcare.openDialog(files, config).done(({ promise, files }) => {
const isGroup = Boolean(files);
return promise().then(info => {
if (isGroup) {
return Promise.all(
files().map(promise => promise.then(fileInfo => buildUrl(fileInfo))),
).then(urls => handleInsert(urls));
} else {
handleInsert(buildUrl(info));
}
});
});
}