Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Weblate 2018-10-29 15:55:18 +00:00
commit 3f7e74142b
2 changed files with 135 additions and 5 deletions

View file

@ -24,8 +24,14 @@ export const baseUrl = `https://${host}`;
const MAX_SERVER_CANDIDATES = 3;
export function makeEventPermalink(roomId, eventId) {
const permalinkBase = `${baseUrl}/#/${roomId}/${eventId}`;
// 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[0] !== '!') return permalinkBase;
const serverCandidates = pickServerCandidates(roomId);
return `${baseUrl}/#/${roomId}/${eventId}?${encodeServerCandidates(serverCandidates)}`;
return `${permalinkBase}${encodeServerCandidates(serverCandidates)}`;
}
export function makeUserPermalink(userId) {
@ -33,8 +39,14 @@ export function makeUserPermalink(userId) {
}
export function makeRoomPermalink(roomId) {
const permalinkBase = `${baseUrl}/#/${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[0] !== '!') return permalinkBase;
const serverCandidates = pickServerCandidates(roomId);
return `${baseUrl}/#/${roomId}?${encodeServerCandidates(serverCandidates)}`;
return `${permalinkBase}${encodeServerCandidates(serverCandidates)}`;
}
export function makeGroupPermalink(groupId) {
@ -42,8 +54,8 @@ export function makeGroupPermalink(groupId) {
}
export function encodeServerCandidates(candidates) {
if (!candidates) return '';
return `via=${candidates.map(c => encodeURIComponent(c)).join("&via=")}`;
if (!candidates || candidates.length === 0) return '';
return `?via=${candidates.map(c => encodeURIComponent(c)).join("&via=")}`;
}
export function pickServerCandidates(roomId) {