Skip to content

Commit 12e9d15

Browse files
authored
Merge pull request #405 from cloudinary/fix/change-storage-to-delivery
remove storage code occurrences
2 parents 17e87e3 + b5ae658 commit 12e9d15

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

__TESTS__/unit/url/url.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ describe('Tests for URL configuration', () => {
3333
expect(image.toURL()).toEqual('https://demo-res.cloudinary.com/images/a_0/sample/hello');
3434
});
3535

36-
it('should only allow `suffix` with a predfined list of storageType/assetType', () => {
36+
it('should only allow `suffix` with a predfined list of deliveryType/assetType', () => {
3737
const image = createNewImage('test')
3838
.setSuffix('abc');
3939

4040
// Suffix only works with predefined SEO_TYPES
4141
Object.keys(SEO_TYPES).forEach((resourceType) => {
42-
const [assetType, storageType] = resourceType.split('/');
42+
const [assetType, deliveryType] = resourceType.split('/');
4343
image.setDeliveryType(assetType)
44-
.setDeliveryType(storageType);
44+
.setDeliveryType(deliveryType);
4545

4646
expect(image.toURL.bind(image)).not.toThrow();
4747
});
4848

49-
// Any other storage type should throw
49+
// Any other delivery type should throw
5050
image.setDeliveryType('fff');
5151
expect(image.toURL.bind(image)).toThrow();
5252
});

src/assets/CloudinaryFile.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
getUrlPrefix,
33
getUrlVersion,
44
handleAssetType,
5-
handleStorageType
5+
handleDeliveryType
66
} from "../internal/url/cloudinaryURL";
77
import {Transformation} from "../transformation/Transformation";
88
import ICloudConfig from "../config/interfaces/Config/ICloudConfig";
@@ -13,7 +13,7 @@ import {getSDKAnalyticsSignature} from "../sdkAnalytics/getSDKAnalyticsSignature
1313
import {ITrackedPropertiesThroughAnalytics} from "../sdkAnalytics/interfaces/ITrackedPropertiesThroughAnalytics";
1414

1515
/**
16-
* This const contains all the valid combination of asset/storage for URL shortening purposes
16+
* This const contains all the valid combination of asset/delivery for URL shortening purposes
1717
* It's exported because it's used in a test, but it's not really shared enough to belong in a separate file
1818
*/
1919
export const SEO_TYPES: Record<string, string> = {
@@ -66,7 +66,7 @@ class CloudinaryFile {
6666
private extension: string;
6767
private signature: string;
6868
private suffix: string;
69-
private storageType: string; // type upload/private
69+
private deliveryType: string; // type upload/private
7070

7171
constructor(publicID: string, cloudConfig: ICloudConfig = {}, urlConfig?: IURLConfig) {
7272
this.setPublicID(publicID);
@@ -114,7 +114,7 @@ class CloudinaryFile {
114114
* @return {this}
115115
*/
116116
setDeliveryType(newType: DELIVERY_TYPE|string): this {
117-
this.storageType = newType;
117+
this.deliveryType = newType;
118118
return this;
119119
}
120120

@@ -195,18 +195,18 @@ class CloudinaryFile {
195195

196196

197197
/**
198-
* @description return an SEO friendly name for a combination of asset/storage, some examples:
198+
* @description return an SEO friendly name for a combination of asset/delivery, some examples:
199199
* * image/upload -> images
200200
* * video/upload -> videos
201-
* If no match is found, return `{asset}/{storage}`
201+
* If no match is found, return `{asset}/{delivery}`
202202
*/
203203
getResourceType(): string {
204204
const assetType = handleAssetType(this.assetType);
205-
const storageType = handleStorageType(this.storageType);
205+
const deliveryType = handleDeliveryType(this.deliveryType);
206206

207207
const hasSuffix = !!this.suffix;
208-
const regularSEOType = `${assetType}/${storageType}`;
209-
const shortSEOType = SEO_TYPES[`${assetType}/${storageType}`];
208+
const regularSEOType = `${assetType}/${deliveryType}`;
209+
const shortSEOType = SEO_TYPES[`${assetType}/${deliveryType}`];
210210
const useRootPath = this.urlConfig.useRootPath;
211211
const shorten = this.urlConfig.shorten;
212212

@@ -215,7 +215,7 @@ class CloudinaryFile {
215215
if (regularSEOType === 'image/upload') {
216216
return ''; // For image/upload we're done, just return nothing
217217
} else {
218-
throw new Error(`useRootPath can only be used with assetType: 'image' and storageType: 'upload'. Provided: ${regularSEOType} instead`);
218+
throw new Error(`useRootPath can only be used with assetType: 'image' and deliveryType: 'upload'. Provided: ${regularSEOType} instead`);
219219
}
220220
}
221221

@@ -232,7 +232,7 @@ class CloudinaryFile {
232232
}
233233
}
234234

235-
// If all else fails, return the regular image/upload combination (asset/storage)
235+
// If all else fails, return the regular image/upload combination (asset/delivery)
236236
return regularSEOType;
237237
}
238238

@@ -270,7 +270,7 @@ class CloudinaryFile {
270270
// we can't use serializeCloudinaryCharacters because that does both things (, and /)
271271
.replace(/,/g, '%2C');
272272

273-
// Resource type is a mixture of assetType, storageType and various URL Configurations
273+
// Resource type is a mixture of assetType, deliveryType and various URL Configurations
274274
// Note how `suffix` changes both image/upload (resourceType) and also is appended at the end
275275
const url = [prefix, this.getResourceType(), this.getSignature(), transformationString, version, publicID, this.suffix]
276276
.filter((a) => a)

src/internal/url/cloudinaryURL.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ function handleAssetType(assetType: string): string {
6565

6666
/**
6767
* @private
68-
* @param storageType
68+
* @param deliveryType
6969
*/
70-
function handleStorageType(storageType: string): string {
70+
function handleDeliveryType(deliveryType: string): string {
7171
//default to upload
72-
if (!storageType) {
72+
if (!deliveryType) {
7373
return 'upload';
7474
}
7575

76-
return storageType;
76+
return deliveryType;
7777
}
7878

7979
/**
@@ -97,4 +97,4 @@ function getUrlVersion(publicID: string, version: number | string, forceVersion:
9797
return shouldForceVersion ? 'v1' : '';
9898
}
9999

100-
export {handleAssetType, getUrlVersion, handleStorageType, getUrlPrefix};
100+
export {handleAssetType, getUrlVersion, handleDeliveryType, getUrlPrefix};

0 commit comments

Comments
 (0)