Merge pull request #3 from matrix-org/main

sync to upstream
This commit is contained in:
Dome
2026-04-07 17:28:24 +02:00
committed by GitHub
3 changed files with 15 additions and 5 deletions
+2
View File
@@ -56,6 +56,8 @@ The matrix.to URL scheme is
The #/ component is mandatory and exists to avoid leaking the target URL to the
server hosting matrix.to.
There is no _Entity type_ for **Spaces**, as they are technically just rooms.
Note that linking to rooms by ID should only be used for rooms to which the
target user has been invited: these links cannot be assumed to work for all
visitors.
+11 -4
View File
@@ -18,7 +18,7 @@ import {createEnum} from "./utils/enum.js";
import {orderedUnique} from "./utils/unique.js";
const ROOMALIAS_PATTERN = /^#([^:]*):(.+)$/;
const ROOMID_PATTERN = /^!([^:]*):(.+)$/;
const ROOMID_PATTERN = /^!([^:]*)(:(.+))?$/; // As of room version 12, room IDs don't have domains
const USERID_PATTERN = /^@([^:]+):(.+)$/;
const EVENTID_PATTERN = /^$([^:]+):(.+)$/;
const GROUPID_PATTERN = /^\+([^:]+):(.+)$/;
@@ -152,7 +152,7 @@ export class Link {
}
matches = ROOMID_PATTERN.exec(identifier);
if (matches) {
const server = matches[2];
const server = matches[3]; // group 2 is an optional over `:domain`, group 3 is just `domain`
const localPart = matches[1];
return new Link(clientId, viaServers, IdentifierKind.RoomId, localPart, server, webInstances, eventId);
}
@@ -166,12 +166,19 @@ export class Link {
}
constructor(clientId, viaServers, identifierKind, localPart, server, webInstances, eventId) {
const servers = [server];
const servers = [];
if (server !== undefined) {
servers.push(server); // v12 rooms don't have domains, and therefore no server
}
servers.push(...viaServers);
this.webInstances = webInstances;
this.servers = orderedUnique(servers);
this.identifierKind = identifierKind;
this.identifier = `${asPrefix(identifierKind)}${localPart}:${server}`;
if (identifierKind === IdentifierKind.RoomId && !server) {
this.identifier = `${asPrefix(identifierKind)}${localPart}`;
} else {
this.identifier = `${asPrefix(identifierKind)}${localPart}:${server}`;
}
this.eventId = eventId;
this.clientId = clientId;
}
+1
View File
@@ -25,6 +25,7 @@ const trustedWebInstances = [
"chat.mozilla.org",
"webchat.kde.org",
"app.gitter.im",
"chat.blender.org",
];
/**