Skip to content

Commit

Permalink
fix regex for overlay msg
Browse files Browse the repository at this point in the history
  • Loading branch information
zhukaihan committed Jun 24, 2024
1 parent 671505a commit 211767b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/experiment-tag/src/messenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ export class WindowMessenger {
) => {
const match =
process.env.NODE_ENV === 'development'
? /^https:\/\/([\w\d]*\.)?amplitude\.com(:3000)?/
: /^https:\/\/.*\.amplitude\.com\//;
if (!match.test(e.origin)) {
? /^([\w\d]*\.)?amplitude\.com(:3000)?/
: /^.*\.amplitude\.com/;
if (!match.test(new URL(e.origin).hostname)) {
return;
}
if (e.data.type === 'OpenOverlay') {
if (state !== 'closed' || !match.test(e.data.context.injectSrc)) {
if (
state !== 'closed' ||
!match.test(new URL(e.data.context.injectSrc).hostname)
) {
return;
}
state = 'opening';
Expand Down

0 comments on commit 211767b

Please sign in to comment.