Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudName required unnecessarily #588

Open
cprussin opened this issue Dec 12, 2023 · 0 comments
Open

cloudName required unnecessarily #588

cprussin opened this issue Dec 12, 2023 · 0 comments

Comments

@cprussin
Copy link

cprussin commented Dec 12, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant