Skip to content

Commit

Permalink
Merge pull request #395 from jdawber/patch-1
Browse files Browse the repository at this point in the history
fix: protect against invalid editable data
  • Loading branch information
fgiuliani authored Jan 10, 2024
2 parents fdc106e + 439c607 commit 1aebb3c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/modules/editable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ export default (blok: SbBlokData) => {
return {};
}

const options = JSON.parse(
blok._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
);
try {
const options = JSON.parse(
blok._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
);

if (options) {
return {
"data-blok-c": JSON.stringify(options),
"data-blok-uid": options.id + "-" + options.uid,
};
}
if (options) {
return {
"data-blok-c": JSON.stringify(options),
"data-blok-uid": options.id + "-" + options.uid,
};
}

return {};
return {};
} catch {
return {};
}
};

0 comments on commit 1aebb3c

Please sign in to comment.