From 35e0b88cbe44b73cd6c7e937cca68ce951978804 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Thu, 23 Nov 2023 15:14:55 -0600 Subject: [PATCH] fix(sdk): prevent lack of parent domain from throwing error --- src/models/sdk.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/models/sdk.ts b/src/models/sdk.ts index 686b449..7452ed3 100644 --- a/src/models/sdk.ts +++ b/src/models/sdk.ts @@ -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