correctly handle MXIDs with not just-domain server names; update testdata config to include that case by default; fixes #239

This commit is contained in:
Aine
2024-12-16 12:53:42 +02:00
parent 630286a781
commit c643bdcfce
2 changed files with 6 additions and 1 deletions

View File

@@ -44,6 +44,11 @@ export function generateRandomMXID(): string {
export function returnMXID(input: string | Identifier): string {
const homeserver = localStorage.getItem("home_server");
// when homeserver is not (just) a domain name, but a domain:port or even an IPv6 address
if (input.endsWith(homeserver) && input.startsWith("@")) {
return input as string; // Already a valid MXID
}
// Check if the input already looks like a valid MXID (i.e., starts with "@" and contains ":")
if (isMXID(input)) {
return input as string; // Already a valid MXID