Skip to content

Commit a581270

Browse files
committed
test: clean up comments
1 parent 713d076 commit a581270

File tree

5 files changed

+2
-19
lines changed

5 files changed

+2
-19
lines changed

__TESTS__/unit/url/url.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,4 @@ describe('Tests for URL configuration', () => {
118118
expect(url).toEqual(`https://res.cloudinary.com/demo/image/upload/sample?_i=abcde&_a=BATAABAQ0`);
119119
});
120120

121-
// TODO: Write test(s): Should include query params as a string
122121
});

src/assets/CloudinaryFile.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -283,22 +283,15 @@ class CloudinaryFile {
283283
.replace(/\?/g, '%3F')
284284
.replace(/=/g, '%3D');
285285

286-
// TODO
287-
// 1. First we have to check if `this.urlConfig.queryParams` is an object and therefore needs parsing
288-
// 2. If we got an object we have to check if URLSearchParams is available, and only then use it
289-
// Beause we want to throw a meaningful Error in case it's not - we can wrap the below code in a try catch clause
290-
// 3. If it already was a string then we can skip the parsing but still we need to assign it to `queryParamsString`
291286

292287
const shouldAddAnalytics = this.urlConfig.analytics !== false && !(publicID.includes('?'));
293288

294289
let queryParamsString = '';
295290

296-
if (typeof(this.urlConfig.queryParams) === 'object'){ //#1
291+
if (typeof(this.urlConfig.queryParams) === 'object'){
297292

298293
try {
299294
const queryParams = new URLSearchParams(this.urlConfig.queryParams as Record<string, string>);
300-
// urlConfig.analytics is true by default, has to be explicitly set to false to overwrite
301-
// Don't add analytics when publicId includes a '?' to not risk changing existing query params
302295

303296
if (shouldAddAnalytics) {
304297
queryParams.set("_a", getSDKAnalyticsSignature(trackedAnalytics));
@@ -307,15 +300,10 @@ class CloudinaryFile {
307300
queryParamsString = queryParams.toString();
308301

309302
} catch(err) {
310-
//TODO: improve error message, consult with docs team.
311303
console.error("Error: URLSearchParams is not available");
312-
//throw "Error: URLSearchParams is not available."; //#2
313304
}
314305
}
315-
316-
//if (typeof(this.urlConfig.queryParams) === 'string'){ //#3
317-
else{ //#3
318-
//assign to queryParamsString
306+
else{
319307
queryParamsString = this.urlConfig.queryParams || '';
320308

321309
if (shouldAddAnalytics) {

src/config/.URLConfig.ts.swp

-12 KB
Binary file not shown.

src/config/URLConfig.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class URLConfig extends Config implements IURLConfig {
1313
useRootPath?: boolean;
1414
secure?: boolean;
1515
forceVersion?: boolean;
16-
// TODO: We need to change the type here to accept string
1716
queryParams?: Record<string, string | number | boolean> | string;
1817

1918
/**
@@ -107,7 +106,6 @@ class URLConfig extends Config implements IURLConfig {
107106
/**
108107
* @param params Sets additional params
109108
*/
110-
// TODO: We need to change the type here to accept string
111109
setQueryParams(params: Record<string, string | number | boolean> | string):this {
112110
this.queryParams = params;
113111
return this;

src/config/interfaces/Config/IURLConfig.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* @prop {boolean} [secure]
1414
* @prop {boolean} [forceVersion]
1515
* @prop {boolean} [analytics]
16-
* // TODO: This is just for generating docs - we need to change the type here to accept string
1716
* @prop {object|string} [queryParams]
1817
* @example
1918
* import Cloudinary from '@cloudinary/url-gen';
@@ -99,7 +98,6 @@ interface IURLConfig {
9998
/**
10099
* Additional params to be added to the URL
101100
*/
102-
// TODO: We need to change the type here to accept string
103101
queryParams?: Record<string, string | number | boolean> | string
104102
}
105103

0 commit comments

Comments
 (0)