@veritree/ui 0.23.0-0 → 0.24.0-0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.23.0-0",
3
+ "version": "0.24.0-0",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -60,12 +60,14 @@ export default {
60
60
  return this.placeholder;
61
61
  }
62
62
 
63
- if (this.cdnSrc) {
64
- return this.handleImageResizing(this.cdnSrc, this.$attrs.width);
63
+ if (this.src) {
64
+ return this.src.includes('cloudfront.net/')
65
+ ? handleImageResizing(this.src, this.$attrs.width)
66
+ : this.src;
65
67
  }
66
68
 
67
- if (this.src) {
68
- return this.src;
69
+ if (this.cdnSrc) {
70
+ return handleImageResizing(this.cdnSrc, this.$attrs.width);
69
71
  }
70
72
  }
71
73
 
@@ -3,42 +3,35 @@ export const handleImageResizing = (url, width) => {
3
3
  if (!url) {
4
4
  return '';
5
5
  }
6
-
6
+
7
7
  let cdn;
8
-
8
+
9
9
  try {
10
- if (typeof url === 'object') {
11
- cdn = url.cdn_url;
12
- }
10
+ // new code
11
+ if (typeof url === 'string' && url.includes('cloudfront.net/')) {
12
+ cdn = url;
13
+ } else {
14
+ // old code
15
+ if (typeof url === 'object') {
16
+ cdn = url.cdn_url;
17
+ }
13
18
 
14
- if (typeof url === 'string') {
15
- cdn = JSON.parse(url).cdn_url;
19
+ if (typeof url === 'string') {
20
+ cdn = JSON.parse(url).cdn_url;
21
+ }
16
22
  }
17
23
 
18
24
  const base64String = cdn.split('net/');
19
25
  const firstPart = base64String[0];
26
+ const decodedString = JSON.parse(atob(base64String[1]));
20
27
 
21
- // if atob is crossed and your editor says is not supported,
22
- // don't worry, it seems to be about NodeJS and not about
23
- // browsers.
24
- //
25
- // Details: https://developer.mozilla.org/en-US/docs/Web/API/atob
26
- const decodedString = JSON.parse(atob(base64String[1]));
27
-
28
- width
29
- ? (decodedString.edits.resize.width = width)
30
- : (decodedString.edits.resize.width = 450);
28
+ decodedString.edits.resize.width = width ?? 450;
31
29
 
32
- // if btoa is crossed and your editor says is not supported,
33
- // don't worry, it seems to be about NodeJS and not about
34
- // browsers.
35
- //
36
- // Details: https://developer.mozilla.org/en-US/docs/Web/API/atob
37
30
  const encodedString = btoa(JSON.stringify(decodedString));
38
31
  const encodedUrl = `${firstPart}net/${encodedString}`;
39
32
 
40
- return encodedUrl
41
- } catch(error) {
33
+ return encodedUrl;
34
+ } catch (error) {
42
35
  console.error(`${error} in ${cdn}`);
43
36
  }
44
- };
37
+ };