forked from Shiloh/remnantchat
fix(sdk): prevent lack of parent domain from throwing error
This commit is contained in:
parent
7bceba5acb
commit
35e0b88cbe
@ -45,8 +45,12 @@ export const isConfigMessageEvent = (
|
||||
event: MessageEvent
|
||||
): event is ConfigMessageEvent => {
|
||||
const queryParams = new URLSearchParams(window.location.search)
|
||||
const parentDomain = queryParams.get(QueryParamKeys.PARENT_DOMAIN)
|
||||
|
||||
if (parentDomain === null) return false
|
||||
|
||||
const { origin: parentFrameOrigin } = new URL(
|
||||
decodeURIComponent(queryParams.get(QueryParamKeys.PARENT_DOMAIN) ?? '')
|
||||
decodeURIComponent(parentDomain)
|
||||
)
|
||||
|
||||
if (event.origin !== parentFrameOrigin) return false
|
||||
|
Loading…
Reference in New Issue
Block a user