@uploadcare/upload-client 6.18.2 → 6.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -405,7 +405,7 @@ const getUrl = (base, path, query) => {
405
405
  return url.toString();
406
406
  };
407
407
 
408
- var version = '6.18.2';
408
+ var version = '6.18.3';
409
409
 
410
410
  const LIBRARY_NAME = 'UploadcareUploadClient';
411
411
  const LIBRARY_VERSION = version;
@@ -1488,6 +1488,20 @@ async function uploadFile(data, { publicKey, fileName, baseURL = defaultSettings
1488
1488
  throw new TypeError(`File uploading from "${data}" is not supported`);
1489
1489
  }
1490
1490
 
1491
+ const replaceUrlBase = (url, newBase) => {
1492
+ try {
1493
+ const originalUrl = new URL(url);
1494
+ const baseUrl = new URL(newBase);
1495
+ originalUrl.protocol = baseUrl.protocol;
1496
+ originalUrl.hostname = baseUrl.hostname;
1497
+ originalUrl.port = baseUrl.port;
1498
+ return originalUrl.toString();
1499
+ }
1500
+ catch {
1501
+ return url;
1502
+ }
1503
+ };
1504
+
1491
1505
  class UploadcareGroup {
1492
1506
  uuid;
1493
1507
  filesCount;
@@ -1506,7 +1520,7 @@ class UploadcareGroup {
1506
1520
  this.isStored = !!groupInfo.datetimeStored;
1507
1521
  this.isImage = !!Object.values(groupFiles).filter((file) => file.isImage)
1508
1522
  .length;
1509
- this.cdnUrl = groupInfo.cdnUrl;
1523
+ this.cdnUrl = replaceUrlBase(groupInfo.cdnUrl, baseCDN);
1510
1524
  this.files = groupFiles.map((fileInfo) => new UploadcareFile(fileInfo, { baseCDN }));
1511
1525
  this.createdAt = groupInfo.datetimeCreated;
1512
1526
  this.storedAt = groupInfo.datetimeStored;
@@ -435,7 +435,7 @@ const getUrl = (base, path, query) => {
435
435
  return url.toString();
436
436
  };
437
437
 
438
- var version = '6.18.2';
438
+ var version = '6.18.3';
439
439
 
440
440
  const LIBRARY_NAME = 'UploadcareUploadClient';
441
441
  const LIBRARY_VERSION = version;
@@ -1519,6 +1519,20 @@ async function uploadFile(data, { publicKey, fileName, baseURL = defaultSettings
1519
1519
  throw new TypeError(`File uploading from "${data}" is not supported`);
1520
1520
  }
1521
1521
 
1522
+ const replaceUrlBase = (url, newBase) => {
1523
+ try {
1524
+ const originalUrl = new URL(url);
1525
+ const baseUrl = new URL(newBase);
1526
+ originalUrl.protocol = baseUrl.protocol;
1527
+ originalUrl.hostname = baseUrl.hostname;
1528
+ originalUrl.port = baseUrl.port;
1529
+ return originalUrl.toString();
1530
+ }
1531
+ catch {
1532
+ return url;
1533
+ }
1534
+ };
1535
+
1522
1536
  class UploadcareGroup {
1523
1537
  uuid;
1524
1538
  filesCount;
@@ -1537,7 +1551,7 @@ class UploadcareGroup {
1537
1551
  this.isStored = !!groupInfo.datetimeStored;
1538
1552
  this.isImage = !!Object.values(groupFiles).filter((file) => file.isImage)
1539
1553
  .length;
1540
- this.cdnUrl = groupInfo.cdnUrl;
1554
+ this.cdnUrl = replaceUrlBase(groupInfo.cdnUrl, baseCDN);
1541
1555
  this.files = groupFiles.map((fileInfo) => new UploadcareFile(fileInfo, { baseCDN }));
1542
1556
  this.createdAt = groupInfo.datetimeCreated;
1543
1557
  this.storedAt = groupInfo.datetimeStored;
@@ -413,7 +413,7 @@ const getUrl = (base, path, query) => {
413
413
  return url.toString();
414
414
  };
415
415
 
416
- var version = '6.18.2';
416
+ var version = '6.18.3';
417
417
 
418
418
  const LIBRARY_NAME = 'UploadcareUploadClient';
419
419
  const LIBRARY_VERSION = version;
@@ -1516,6 +1516,20 @@ async function uploadFile(data, { publicKey, fileName, baseURL = defaultSettings
1516
1516
  throw new TypeError(`File uploading from "${data}" is not supported`);
1517
1517
  }
1518
1518
 
1519
+ const replaceUrlBase = (url, newBase) => {
1520
+ try {
1521
+ const originalUrl = new URL(url);
1522
+ const baseUrl = new URL(newBase);
1523
+ originalUrl.protocol = baseUrl.protocol;
1524
+ originalUrl.hostname = baseUrl.hostname;
1525
+ originalUrl.port = baseUrl.port;
1526
+ return originalUrl.toString();
1527
+ }
1528
+ catch {
1529
+ return url;
1530
+ }
1531
+ };
1532
+
1519
1533
  class UploadcareGroup {
1520
1534
  uuid;
1521
1535
  filesCount;
@@ -1534,7 +1548,7 @@ class UploadcareGroup {
1534
1548
  this.isStored = !!groupInfo.datetimeStored;
1535
1549
  this.isImage = !!Object.values(groupFiles).filter((file) => file.isImage)
1536
1550
  .length;
1537
- this.cdnUrl = groupInfo.cdnUrl;
1551
+ this.cdnUrl = replaceUrlBase(groupInfo.cdnUrl, baseCDN);
1538
1552
  this.files = groupFiles.map((fileInfo) => new UploadcareFile(fileInfo, { baseCDN }));
1539
1553
  this.createdAt = groupInfo.datetimeCreated;
1540
1554
  this.storedAt = groupInfo.datetimeStored;
@@ -403,7 +403,7 @@ const getUrl = (base, path, query) => {
403
403
  return url.toString();
404
404
  };
405
405
 
406
- var version = '6.18.2';
406
+ var version = '6.18.3';
407
407
 
408
408
  const LIBRARY_NAME = 'UploadcareUploadClient';
409
409
  const LIBRARY_VERSION = version;
@@ -1486,6 +1486,20 @@ async function uploadFile(data, { publicKey, fileName, baseURL = defaultSettings
1486
1486
  throw new TypeError(`File uploading from "${data}" is not supported`);
1487
1487
  }
1488
1488
 
1489
+ const replaceUrlBase = (url, newBase) => {
1490
+ try {
1491
+ const originalUrl = new URL(url);
1492
+ const baseUrl = new URL(newBase);
1493
+ originalUrl.protocol = baseUrl.protocol;
1494
+ originalUrl.hostname = baseUrl.hostname;
1495
+ originalUrl.port = baseUrl.port;
1496
+ return originalUrl.toString();
1497
+ }
1498
+ catch {
1499
+ return url;
1500
+ }
1501
+ };
1502
+
1489
1503
  class UploadcareGroup {
1490
1504
  uuid;
1491
1505
  filesCount;
@@ -1504,7 +1518,7 @@ class UploadcareGroup {
1504
1518
  this.isStored = !!groupInfo.datetimeStored;
1505
1519
  this.isImage = !!Object.values(groupFiles).filter((file) => file.isImage)
1506
1520
  .length;
1507
- this.cdnUrl = groupInfo.cdnUrl;
1521
+ this.cdnUrl = replaceUrlBase(groupInfo.cdnUrl, baseCDN);
1508
1522
  this.files = groupFiles.map((fileInfo) => new UploadcareFile(fileInfo, { baseCDN }));
1509
1523
  this.createdAt = groupInfo.datetimeCreated;
1510
1524
  this.storedAt = groupInfo.datetimeStored;
@@ -433,7 +433,7 @@ const getUrl = (base, path, query) => {
433
433
  return url.toString();
434
434
  };
435
435
 
436
- var version = '6.18.2';
436
+ var version = '6.18.3';
437
437
 
438
438
  const LIBRARY_NAME = 'UploadcareUploadClient';
439
439
  const LIBRARY_VERSION = version;
@@ -1517,6 +1517,20 @@ async function uploadFile(data, { publicKey, fileName, baseURL = defaultSettings
1517
1517
  throw new TypeError(`File uploading from "${data}" is not supported`);
1518
1518
  }
1519
1519
 
1520
+ const replaceUrlBase = (url, newBase) => {
1521
+ try {
1522
+ const originalUrl = new URL(url);
1523
+ const baseUrl = new URL(newBase);
1524
+ originalUrl.protocol = baseUrl.protocol;
1525
+ originalUrl.hostname = baseUrl.hostname;
1526
+ originalUrl.port = baseUrl.port;
1527
+ return originalUrl.toString();
1528
+ }
1529
+ catch {
1530
+ return url;
1531
+ }
1532
+ };
1533
+
1520
1534
  class UploadcareGroup {
1521
1535
  uuid;
1522
1536
  filesCount;
@@ -1535,7 +1549,7 @@ class UploadcareGroup {
1535
1549
  this.isStored = !!groupInfo.datetimeStored;
1536
1550
  this.isImage = !!Object.values(groupFiles).filter((file) => file.isImage)
1537
1551
  .length;
1538
- this.cdnUrl = groupInfo.cdnUrl;
1552
+ this.cdnUrl = replaceUrlBase(groupInfo.cdnUrl, baseCDN);
1539
1553
  this.files = groupFiles.map((fileInfo) => new UploadcareFile(fileInfo, { baseCDN }));
1540
1554
  this.createdAt = groupInfo.datetimeCreated;
1541
1555
  this.storedAt = groupInfo.datetimeStored;
@@ -411,7 +411,7 @@ const getUrl = (base, path, query) => {
411
411
  return url.toString();
412
412
  };
413
413
 
414
- var version = '6.18.2';
414
+ var version = '6.18.3';
415
415
 
416
416
  const LIBRARY_NAME = 'UploadcareUploadClient';
417
417
  const LIBRARY_VERSION = version;
@@ -1514,6 +1514,20 @@ async function uploadFile(data, { publicKey, fileName, baseURL = defaultSettings
1514
1514
  throw new TypeError(`File uploading from "${data}" is not supported`);
1515
1515
  }
1516
1516
 
1517
+ const replaceUrlBase = (url, newBase) => {
1518
+ try {
1519
+ const originalUrl = new URL(url);
1520
+ const baseUrl = new URL(newBase);
1521
+ originalUrl.protocol = baseUrl.protocol;
1522
+ originalUrl.hostname = baseUrl.hostname;
1523
+ originalUrl.port = baseUrl.port;
1524
+ return originalUrl.toString();
1525
+ }
1526
+ catch {
1527
+ return url;
1528
+ }
1529
+ };
1530
+
1517
1531
  class UploadcareGroup {
1518
1532
  uuid;
1519
1533
  filesCount;
@@ -1532,7 +1546,7 @@ class UploadcareGroup {
1532
1546
  this.isStored = !!groupInfo.datetimeStored;
1533
1547
  this.isImage = !!Object.values(groupFiles).filter((file) => file.isImage)
1534
1548
  .length;
1535
- this.cdnUrl = groupInfo.cdnUrl;
1549
+ this.cdnUrl = replaceUrlBase(groupInfo.cdnUrl, baseCDN);
1536
1550
  this.files = groupFiles.map((fileInfo) => new UploadcareFile(fileInfo, { baseCDN }));
1537
1551
  this.createdAt = groupInfo.datetimeCreated;
1538
1552
  this.storedAt = groupInfo.datetimeStored;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadcare/upload-client",
3
- "version": "6.18.2",
3
+ "version": "6.18.3",
4
4
  "description": "Library for work with Uploadcare Upload API",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.node.mjs",
@@ -83,7 +83,7 @@
83
83
  "@types/koa__cors": "^5.0.0",
84
84
  "@types/koa__router": "^12.0.4",
85
85
  "@types/ws": "8.5.3",
86
- "@uploadcare/api-client-utils": "^6.18.2",
86
+ "@uploadcare/api-client-utils": "^6.18.3",
87
87
  "chalk": "^4.1.2",
88
88
  "data-uri-to-buffer": "3.0.1",
89
89
  "dataurl-to-blob": "0.0.1",