Skip to content

Commit

Permalink
SKY-6550 Catch messenger error (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhukaihan authored Nov 21, 2024
1 parent 9fb06dc commit 64cbec3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/experiment-tag/src/messenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ export class WindowMessenger {
}>,
) => {
const match = /^.*\.amplitude\.com$/;
if (!e.origin || !match.test(new URL(e.origin).hostname)) {
try {
if (!e.origin || !match.test(new URL(e.origin).hostname)) {
return;
}
} catch {
// The security check failed on exception, return without throwing.
// new URL(e.origin) can throw.
return;
}
if (e.data.type === 'OpenOverlay') {
Expand Down

0 comments on commit 64cbec3

Please sign in to comment.