fix: make room directory correct when using a homeserver with explicit port

Server names are allowed to contain ':' to specify a port, see https://matrix.org/docs/spec/appendices#server-name
User ids on the other hand are not allowed to contain ':', even
historical user ids, see https://matrix.org/docs/spec/appendices#historical-user-ids

Therefore we can use change the regex to make sure the localpart is not
allowed to contain ':'.
pull/21833/head
Timo Kösters 2021-03-15 23:13:16 +01:00
parent 3154dd6cd4
commit f575625c7a
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
1 changed files with 1 additions and 1 deletions

View File

@ -261,7 +261,7 @@ class _MatrixClientPeg implements IMatrixClientPeg {
} }
public getHomeserverName(): string { public getHomeserverName(): string {
const matches = /^@.+:(.+)$/.exec(this.matrixClient.credentials.userId); const matches = /^@[^:]+:(.+)$/.exec(this.matrixClient.credentials.userId);
if (matches === null || matches.length < 1) { if (matches === null || matches.length < 1) {
throw new Error("Failed to derive homeserver name from user ID!"); throw new Error("Failed to derive homeserver name from user ID!");
} }