Skip to content

cloudName required unnecessarily #588

@cprussin

Description

@cprussin

In

validateAssetForURLCreation(): void {
if (typeof this.cloudName === 'undefined') {
throw 'You must supply a cloudName when initializing the asset';
}
const suffixContainsDot = this.suffix && this.suffix.indexOf('.') >= 0;
const suffixContainsSlash = this.suffix && this.suffix.indexOf('/') >= 0;
if (suffixContainsDot || suffixContainsSlash) {
throw '`suffix`` should not include . or /';
}
}
a cloudName setting is explicitly required. However, in
function getUrlPrefix(cloudName: string, urlConfig: IURLConfig): string {
const secure = urlConfig.secure;
const privateCDN = urlConfig.privateCdn;
const cname = urlConfig.cname;
const secureDistribution = urlConfig.secureDistribution;
if (!secure && !cname) {
return `http://res.cloudinary.com/${cloudName}`;
}
if (secure && !secureDistribution && privateCDN) {
return `https://${cloudName}-res.cloudinary.com`;
}
if (secure && !secureDistribution) {
return `https://res.cloudinary.com/${cloudName}`;
}
if (secure && secureDistribution && privateCDN) {
return `https://${secureDistribution}`;
}
if (secure && secureDistribution) {
return `https://${secureDistribution}/${cloudName}`;
}
if (!secure && cname) {
return `http://${cname}/${cloudName}`;
} else {
return 'ERROR';
}
}
the cloudName isn't actually even utilized if using a secureDistribution and privateCDN.

The check for cloudName should be moved into getUrlPrefix and we should only throw when omitting the cloud name for branches where it's actually utilized.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions