pi-hashline-edit-pro 0.13.2 → 0.13.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.
- package/package.json +1 -1
- package/src/replace-normalize.ts +20 -5
package/package.json
CHANGED
package/src/replace-normalize.ts
CHANGED
|
@@ -42,14 +42,29 @@ export function normReq(input: unknown): unknown {
|
|
|
42
42
|
const hasChangesField = has(record, "changes");
|
|
43
43
|
const hasEditsField = has(record, "edits");
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
if (hasChangesField) {
|
|
46
46
|
const raw = tryParseJSON(record.changes, Array.isArray) ?? record.changes;
|
|
47
|
-
if (Array.isArray(raw))
|
|
48
|
-
|
|
47
|
+
if (Array.isArray(raw)) {
|
|
48
|
+
record.changes = coerceEditArray(raw);
|
|
49
|
+
} else {
|
|
50
|
+
// Single object (JSON string or literal) → wrap in array
|
|
51
|
+
const single = typeof raw === "string"
|
|
52
|
+
? tryParseJSON(raw, isRec)
|
|
53
|
+
: isRec(raw) ? raw : undefined;
|
|
54
|
+
if (single) record.changes = coerceEditArray([single]);
|
|
55
|
+
}
|
|
56
|
+
} else if (hasEditsField) {
|
|
49
57
|
const raw = tryParseJSON(record.edits, Array.isArray) ?? record.edits;
|
|
50
|
-
if (Array.isArray(raw))
|
|
58
|
+
if (Array.isArray(raw)) {
|
|
59
|
+
record.changes = coerceEditArray(raw);
|
|
60
|
+
} else {
|
|
61
|
+
const single = typeof raw === "string"
|
|
62
|
+
? tryParseJSON(raw, isRec)
|
|
63
|
+
: isRec(raw) ? raw : undefined;
|
|
64
|
+
if (single) record.changes = coerceEditArray([single]);
|
|
65
|
+
}
|
|
51
66
|
delete record.edits;
|
|
52
|
-
|
|
67
|
+
}
|
|
53
68
|
|
|
54
69
|
return record;
|
|
55
70
|
}
|