From acc4cc9fc791b6102bfd4fac91ed3a08842b7740 Mon Sep 17 00:00:00 2001 From: Timo K Date: Thu, 31 Aug 2023 12:46:00 +0200 Subject: [PATCH] make wildcard (*) a possible parentUrl Signed-off-by: Timo K --- src/widget.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widget.ts b/src/widget.ts index de03d78e..16f30624 100644 --- a/src/widget.ts +++ b/src/widget.ts @@ -75,7 +75,9 @@ export const widget: WidgetHelpers | null = (() => { const parentUrl = query.get("parentUrl"); if (widgetId && parentUrl) { - const parentOrigin = new URL(parentUrl).origin; + // Allow * (wildcard) as the parentOrigin. This is needed if the widget does + // not run in an IFrame and instead needs to send the messages to the webview itself. + const parentOrigin = parentUrl === "*" ? "*" : new URL(parentUrl).origin; logger.info("Widget API is available"); const api = new WidgetApi(widgetId, parentOrigin); api.requestCapability(MatrixCapabilities.AlwaysOnScreen);