diff --git a/src/UrlParams.ts b/src/UrlParams.ts index 90713c3b..8facbcaa 100644 --- a/src/UrlParams.ts +++ b/src/UrlParams.ts @@ -33,6 +33,9 @@ interface RoomIdentifier { // clearer what each flag means, and helps us avoid coupling Element Call's // behavior to the needs of specific consumers. interface UrlParams { + // Widget api related params + widgetId: string | null; + parentUrl: string | null; /** * Anything about what room we're pointed to should be from useRoomIdentifier which * parses the path and resolves alias with respect to the default server name, however @@ -178,6 +181,9 @@ export const getUrlParams = ( const fontScale = parseFloat(parser.getParam("fontScale") ?? ""); return { + widgetId: parser.getParam("widgetId"), + parentUrl: parser.getParam("parentUrl"), + // NB. we don't validate roomId here as we do in getRoomIdentifierFromUrl: // what would we do if it were invalid? If the widget API says that's what // the room ID is, then that's what it is. diff --git a/src/widget.ts b/src/widget.ts index 12b54849..55b8047e 100644 --- a/src/widget.ts +++ b/src/widget.ts @@ -70,9 +70,7 @@ interface WidgetHelpers { */ export const widget: WidgetHelpers | null = (() => { try { - const query = new URLSearchParams(window.location.search); - const widgetId = query.get("widgetId"); - const parentUrl = query.get("parentUrl"); + const { widgetId, parentUrl } = getUrlParams(); if (widgetId && parentUrl) { const parentOrigin = new URL(parentUrl).origin;