turn NPE into a throw

pull/21833/head
Matthew Hodgson 2019-04-04 16:53:17 +01:00
parent e98ef0d537
commit b9eebee13b
1 changed files with 5 additions and 1 deletions

View File

@ -239,9 +239,13 @@ export function makeUserPermalink(userId) {
export function makeRoomPermalink(roomId) {
const permalinkBase = `${baseUrl}/#/${roomId}`;
if (!roomId) {
throw new Error("can't permalink a falsey roomId");
}
// If the roomId isn't actually a room ID, don't try to list the servers.
// Aliases are already routable, and don't need extra information.
if (!roomId || roomId[0] !== '!') return permalinkBase;
if (roomId[0] !== '!') return permalinkBase;
const client = MatrixClientPeg.get();
const room = client.getRoom(roomId);