pangea-server 3.3.80 → 3.3.81

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.
@@ -62,6 +62,13 @@ async function setFilesUrls(data) {
62
62
  const k = key.toLowerCase();
63
63
  return k.includes('image') || k.includes('video');
64
64
  }
65
+ function normalizeArray(value) {
66
+ if (Array.isArray(value))
67
+ return value;
68
+ if (typeof value === 'string' && value.length)
69
+ return value.split(',').map((v) => v.trim()).filter(Boolean);
70
+ return [];
71
+ }
65
72
  function collect(node) {
66
73
  if (!node)
67
74
  return;
@@ -76,11 +83,24 @@ async function setFilesUrls(data) {
76
83
  visited.add(node);
77
84
  for (const [key, value] of Object.entries(node)) {
78
85
  if (isTargetKey(key)) {
79
- if (Array.isArray(value) && value.every((v) => typeof v === 'string')) {
80
- arrayTargets.push({ node, key });
81
- }
82
- else if (typeof value === 'string') {
83
- singleTargets.push({ node, key });
86
+ if (Array.isArray(value) || typeof value === 'string') {
87
+ const arr = normalizeArray(value);
88
+ if (arr.length > 1) {
89
+ node[key] = arr;
90
+ arrayTargets.push({ node, key });
91
+ }
92
+ else if (arr.length === 1) {
93
+ node[key] = arr[0];
94
+ singleTargets.push({ node, key });
95
+ }
96
+ else if (Array.isArray(value)) {
97
+ node[key] = [];
98
+ arrayTargets.push({ node, key });
99
+ }
100
+ else {
101
+ node[key] = null;
102
+ singleTargets.push({ node, key });
103
+ }
84
104
  }
85
105
  }
86
106
  collect(value);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "3.3.80",
4
+ "version": "3.3.81",
5
5
  "files": [
6
6
  "dist"
7
7
  ],