fix(tauri): use getAppOrigin() for all origin-dependent paths

This commit is contained in:
Erwan Leboucher committed 2026-07-17 18:18:50 +02:00
1 parent 213b1b8e3a
commit 5670c9ef3f
4 files changed
+19 -11

No files matched your search

+5 -9
View File
@@ -10,6 +10,7 @@ import {
} from 'matrix-widget-api';
import { CallWidgetDriver } from './CallWidgetDriver';
import { trimTrailingSlash } from '../../utils/common';
import { getAppOrigin } from '../../utils/platform';
import type { ElementCallThemeKind, ElementMediaStateDetail } from './types';
import { color, config } from 'folds';
import { ElementCallIntent, ElementWidgetActions } from './types';
@@ -96,12 +97,7 @@ export class CallEmbed {
): Widget {
const userId = mx.getSafeUserId();
const deviceId = mx.getDeviceId() ?? '';
// window.location.origin is "null" on Tauri (tauri:// is opaque per WHATWG).
// The widget does new URL(parentUrl), which throws on "null".
const clientOrigin =
window.location.origin === 'null'
? `${window.location.protocol}//${window.location.host}`
: window.location.origin;
const clientOrigin = getAppOrigin();
const widgetId = 'call-embed';
const params = new URLSearchParams({
@@ -130,7 +126,7 @@ export class CallEmbed {
let widgetUrl: URL;
if (elementCallUrl && elementCallUrl.trim()) {
try {
widgetUrl = new URL(elementCallUrl, window.location.origin);
widgetUrl = new URL(elementCallUrl, clientOrigin);
} catch (error) {
debugLog.warn(
'call',
@@ -142,13 +138,13 @@ export class CallEmbed {
);
widgetUrl = new URL(
`${trimTrailingSlash(import.meta.env.BASE_URL)}/public/element-call/index.html`,
window.location.origin
clientOrigin
);
}
} else {
widgetUrl = new URL(
`${trimTrailingSlash(import.meta.env.BASE_URL)}/public/element-call/index.html`,
window.location.origin
clientOrigin
);
}
widgetUrl.search = params.toString();