diff --git a/src/UrlParams.ts b/src/UrlParams.ts index 82a08801..85071eb6 100644 --- a/src/UrlParams.ts +++ b/src/UrlParams.ts @@ -19,7 +19,7 @@ import { useLocation } from "react-router-dom"; import { Config } from "./config/Config"; -export const PASSWORD_STRING = "?password="; +export const PASSWORD_STRING = "password="; interface UrlParams { roomAlias: string | null; @@ -109,17 +109,8 @@ export const getUrlParams = ( hash = window.location.hash ): UrlParams => { let roomAlias: string | null = null; - let password: string | null = null; - - const passwordIndex = hash.indexOf(PASSWORD_STRING); - const passwordStart = - passwordIndex === -1 ? null : passwordIndex + PASSWORD_STRING.length; - if (passwordStart) { - password = hash.substring(passwordStart); - } - if (!ignoreRoomAlias) { - if (hash === "" || hash.startsWith("#" + PASSWORD_STRING)) { + if (hash === "" || hash.startsWith("#?")) { roomAlias = pathname.substring(1); // Strip the "/" // Delete "/room/", if present @@ -179,7 +170,7 @@ export const getUrlParams = ( return { roomAlias, roomId, - password, + password: getParam("password"), viaServers: getAllParams("via"), isEmbedded: hasParam("embed"), preload: hasParam("preload"), diff --git a/src/matrix-utils.ts b/src/matrix-utils.ts index e60f5345..ba76b665 100644 --- a/src/matrix-utils.ts +++ b/src/matrix-utils.ts @@ -347,7 +347,7 @@ export function getRoomUrl( roomIdOrAlias: string, password: string = "" ): string { - password = password === "" ? "" : "#" + PASSWORD_STRING + password; + password = password === "" ? "" : "#?" + PASSWORD_STRING + password; if (roomIdOrAlias.startsWith("#")) { return `${window.location.protocol}//${window.location.host}/${ diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index cf3aa341..b528d9ce 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -257,13 +257,15 @@ export function GroupCallView({ }, [password, e2eeSharedKey, setE2EESharedKey]); useEffect(() => { - const originalHash = location.hash; - const hash = originalHash === "" ? "#" : originalHash; - const [hashStart, password] = hash.split(PASSWORD_STRING); + const hash = location.hash; + if (!hash.includes("?")) return; + + const [hashStart, passwordStart] = hash.split(PASSWORD_STRING); + const [password, hashEnd] = passwordStart ? passwordStart.split("&") : []; if (password !== e2eeSharedKey) return; - location.replace(hashStart); + location.replace((hashStart ?? "") + (hashEnd ?? "")); }, [password, e2eeSharedKey]); const e2eeConfig = useMemo(