Skip to content

Commit ced2b85

Browse files
authored
Merge pull request #1949 from contentstack/fix/audit
Optional Check
2 parents 6446419 + 40e9120 commit ced2b85

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

packages/contentstack-audit/src/modules/entries.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ export default class Entries {
116116
const { uid, title } = entry;
117117
this.currentUid = uid;
118118
this.currentTitle = title;
119-
this.currentTitle = this.removeEmojiAndImages(this.currentTitle)
119+
if (this.currentTitle) {
120+
this.currentTitle = this.removeEmojiAndImages(this.currentTitle);
121+
}
120122

121123
if (!this.missingRefs[this.currentUid]) {
122124
this.missingRefs[this.currentUid] = [];
@@ -133,7 +135,11 @@ export default class Entries {
133135
this.removeMissingKeysOnEntry(ctSchema.schema as ContentTypeSchemaType[], this.entries[entryUid]);
134136
}
135137

136-
this.lookForReference([{ locale: code, uid, name: this.removeEmojiAndImages(title) }], ctSchema, this.entries[entryUid]);
138+
this.lookForReference(
139+
[{ locale: code, uid, name: this.removeEmojiAndImages(this.currentTitle) }],
140+
ctSchema,
141+
this.entries[entryUid],
142+
);
137143

138144
if (this.missingRefs[this.currentUid]?.length) {
139145
this.missingRefs[this.currentUid].forEach((entry: any) => {
@@ -242,7 +248,7 @@ export default class Entries {
242248
missingMandatoryFields: this.missingMandatoryFields,
243249
missingTitleFields: this.missingTitleFields,
244250
missingEnvLocale: this.missingEnvLocale,
245-
missingMultipleFields: this.missingMultipleField
251+
missingMultipleFields: this.missingMultipleField,
246252
};
247253
}
248254

@@ -354,11 +360,11 @@ export default class Entries {
354360
for (const child of field?.schema ?? []) {
355361
const { uid, multiple, data_type } = child;
356362

357-
if(multiple && entry[uid] && !Array.isArray(entry[uid])) {
358-
if (!this.missingMultipleField[this.currentUid]) {
359-
this.missingMultipleField[this.currentUid] = [];
360-
}
361-
363+
if (multiple && entry[uid] && !Array.isArray(entry[uid])) {
364+
if (!this.missingMultipleField[this.currentUid]) {
365+
this.missingMultipleField[this.currentUid] = [];
366+
}
367+
362368
this.missingMultipleField[this.currentUid].push({
363369
uid: this.currentUid,
364370
name: this.currentTitle,
@@ -371,7 +377,7 @@ export default class Entries {
371377
.filter((val) => val)
372378
.join(' ➜ '),
373379
});
374-
}
380+
}
375381
this.missingMandatoryFields[this.currentUid].push(
376382
...this.validateMandatoryFields(
377383
[...tree, { uid: field.uid, name: child.display_name, field: uid }],
@@ -758,7 +764,7 @@ export default class Entries {
758764
.map(({ name }) => name)
759765
.filter(Boolean)
760766
.join(' ➜ '),
761-
'fixStatus': 'Fixed',
767+
fixStatus: 'Fixed',
762768
});
763769

764770
entry[uid] = [entry[uid]];
@@ -842,7 +848,7 @@ export default class Entries {
842848
* Else empty array
843849
*/
844850
removeEmojiAndImages(str: string) {
845-
return str.replace(
851+
return str?.replace(
846852
/[\p{Emoji}\p{Emoji_Presentation}\p{Emoji_Modifier}\p{Emoji_Modifier_Base}\p{Emoji_Component}]+/gu,
847853
'',
848854
);

0 commit comments

Comments
 (0)