Skip to content

Commit 91cc738

Browse files
authored
Merge pull request #454 from coderoad/fix/handle-origin
ensure events come from cr webview
2 parents 9c581dd + c70ee1c commit 91cc738

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

web-app/src/services/state/useStateMachine.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ const useStateMachine = (): Output => {
3333
const listener = 'message'
3434
// propograte channel event to state machine
3535
const handler = (event: any) => {
36-
// NOTE: must call event.data, cannot destructure. VSCode acts odd
37-
const action = event.data
38-
// ignore browser events from other extensions
39-
if (action.source) {
36+
// ensure events are coming from coderoad webview
37+
if (!event.origin.match(/^vscode-webview/)) {
4038
return
4139
}
40+
// NOTE: must call event.data, cannot destructure. VSCode acts odd
41+
const action = event.data
4242
sendWithLog(action)
4343
}
4444
window.addEventListener(listener, handler)

0 commit comments

Comments
 (0)