Skip to content

Commit 37379ec

Browse files
authored
fix(playground): validate console messages (#10962)
1 parent b1cf84e commit 37379ec

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: client/src/playground/index.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,19 @@ export default function Playground() {
123123
if (typ === "console") {
124124
if (prop === "clear") {
125125
setVConsole([]);
126-
} else {
126+
} else if (
127+
(prop === "log" || prop === "error" || prop === "warn") &&
128+
typeof message === "string"
129+
) {
127130
setVConsole((vConsole) => [...vConsole, { prop, message }]);
131+
} else {
132+
setVConsole((vConsole) => [
133+
...vConsole,
134+
{
135+
prop: "warn",
136+
message: `[Playground] Unsupported console message: ${JSON.stringify({ prop, message }, null, 2)}`,
137+
},
138+
]);
128139
}
129140
} else if (typ === "ready") {
130141
updatePlayIframe(iframe.current, getEditorContent());

0 commit comments

Comments
 (0)