Skip to content

Commit

Permalink
fix: don't fail when both desciriptions are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikZed committed Sep 6, 2024
1 parent 1289379 commit 863ae34
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/integration-saleor-entities/src/editorjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ class EditorJSHelper {
* just compares the blocks and data of the blocks. Returns true if they are the same.
*/
public compareEditorJsData(data1: string, data2: string): boolean {
if (!data1 && !data2) {
return true;
}
const normalizedData1 = this.normalizeEditorJSData(JSON.parse(data1));
const normalizedData2 = this.normalizeEditorJSData(JSON.parse(data2));

Expand All @@ -169,7 +172,7 @@ class EditorJSHelper {

private normalizeEditorJSData(data: any): object {
// Sort blocks to ensure order does not matter
if (!data.blocks) {
if (!data?.blocks) {
throw new Error("Invalid EditorJS data. Can't compare");
}
const sortedBlocks = data.blocks.map((block: any) => {
Expand Down

0 comments on commit 863ae34

Please sign in to comment.