Skip to content

Commit

Permalink
fix(playground): validate console messages (#10962)
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Apr 22, 2024
1 parent b1cf84e commit 37379ec
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion client/src/playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,19 @@ export default function Playground() {
if (typ === "console") {
if (prop === "clear") {
setVConsole([]);
} else {
} else if (
(prop === "log" || prop === "error" || prop === "warn") &&
typeof message === "string"
) {
setVConsole((vConsole) => [...vConsole, { prop, message }]);
} else {
setVConsole((vConsole) => [
...vConsole,
{
prop: "warn",
message: `[Playground] Unsupported console message: ${JSON.stringify({ prop, message }, null, 2)}`,
},
]);
}
} else if (typ === "ready") {
updatePlayIframe(iframe.current, getEditorContent());
Expand Down

0 comments on commit 37379ec

Please sign in to comment.