-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
In
js-url-gen/src/assets/CloudinaryFile.ts
Lines 182 to 193 in e1b9719
| 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 /'; | |
| } | |
| } |
cloudName setting is explicitly required. However, in js-url-gen/src/internal/url/cloudinaryURL.ts
Lines 20 to 51 in e1b9719
| 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'; | |
| } | |
| } |
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
Labels
No labels