diff --git a/src/UrlParams.ts b/src/UrlParams.ts
index 4a37254a..700c8154 100644
--- a/src/UrlParams.ts
+++ b/src/UrlParams.ts
@@ -102,12 +102,12 @@ export const getUrlParams = (
pathname = window.location.pathname,
hash = window.location.hash
): UrlParams => {
- let roomAlias: string | undefined;
+ let roomAlias: string | null = null;
if (!ignoreRoomAlias) {
if (hash === "") {
roomAlias = pathname.substring(1); // Strip the "/"
- // Delete "/room/" and "?", if present
+ // Delete "/room/", if present
if (roomAlias.startsWith("room/")) {
roomAlias = roomAlias.substring("room/".length);
}
@@ -123,6 +123,14 @@ export const getUrlParams = (
if (!roomAlias.includes(":")) {
roomAlias = `${roomAlias}:${Config.defaultServerName()}`;
}
+
+ // Delete "?" and what comes afterwards
+ roomAlias = roomAlias.split("?")[0];
+
+ // Make roomAlias undefined, if empty
+ if (roomAlias.length <= 1) {
+ roomAlias = null;
+ }
}
const fragmentQueryStart = hash.indexOf("?");
@@ -145,9 +153,17 @@ export const getUrlParams = (
const fontScale = parseFloat(getParam("fontScale") ?? "");
+ // Make sure roomId is valid
+ let roomId: string | null = getParam("roomId");
+ if (!roomId?.startsWith("!")) {
+ roomId = null;
+ } else if (!roomId.includes("")) {
+ roomId = null;
+ }
+
return {
- roomAlias: !roomAlias || roomAlias.includes("!") ? null : roomAlias,
- roomId: getParam("roomId"),
+ roomAlias,
+ roomId,
viaServers: getAllParams("via"),
isEmbedded: hasParam("embed"),
preload: hasParam("preload"),
diff --git a/src/room/RoomPage.tsx b/src/room/RoomPage.tsx
index afd7beca..ddf92959 100644
--- a/src/room/RoomPage.tsx
+++ b/src/room/RoomPage.tsx
@@ -15,7 +15,6 @@ limitations under the License.
*/
import { FC, useEffect, useState, useCallback } from "react";
-import { useTranslation } from "react-i18next";
import type { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall";
import { useClientLegacy } from "../ClientContext";
@@ -25,12 +24,10 @@ import { GroupCallLoader } from "./GroupCallLoader";
import { GroupCallView } from "./GroupCallView";
import { useUrlParams } from "../UrlParams";
import { useRegisterPasswordlessUser } from "../auth/useRegisterPasswordlessUser";
-import { translatedError } from "../TranslatedError";
import { useOptInAnalytics } from "../settings/useSetting";
+import { HomePage } from "../home/HomePage";
export const RoomPage: FC = () => {
- const { t } = useTranslation();
-
const {
roomAlias,
roomId,
@@ -42,7 +39,9 @@ export const RoomPage: FC = () => {
displayName,
} = useUrlParams();
const roomIdOrAlias = roomId ?? roomAlias;
- if (!roomIdOrAlias) throw translatedError("No room specified", t);
+ if (!roomIdOrAlias) {
+ console.error("No room specified");
+ }
const [optInAnalytics, setOptInAnalytics] = useOptInAnalytics();
const { registerPasswordlessUser } = useRegisterPasswordlessUser();
@@ -99,6 +98,10 @@ export const RoomPage: FC = () => {
return ;
}
+ if (!roomIdOrAlias) {
+ return ;
+ }
+
return (