URLencode identifiers
This commit is contained in:
parent
b8e07cda7e
commit
ee820b6ca1
1 changed files with 6 additions and 2 deletions
|
@ -30,6 +30,10 @@ export const IdentifierKind = createEnum(
|
||||||
"GroupId",
|
"GroupId",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function idToPath(identifier) {
|
||||||
|
return encodeURIComponent(identifier.substring(1));
|
||||||
|
}
|
||||||
|
|
||||||
function asPrefix(identifierKind) {
|
function asPrefix(identifierKind) {
|
||||||
switch (identifierKind) {
|
switch (identifierKind) {
|
||||||
case IdentifierKind.RoomId: return "!";
|
case IdentifierKind.RoomId: return "!";
|
||||||
|
@ -200,8 +204,8 @@ export class Link {
|
||||||
// Some matrix.to links aren't valid matrix: links (i.e. groups)
|
// Some matrix.to links aren't valid matrix: links (i.e. groups)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const identifier = this.identifier.substring(1);
|
const identifier = idToPath(this.identifier);
|
||||||
const suffix = this.eventId ? `/e/${this.eventId.substring(1)}` : "";
|
const suffix = this.eventId ? `/e/${idToPath(this.eventId)}` : "";
|
||||||
return `matrix:${prefix}/${identifier}${suffix}`;
|
return `matrix:${prefix}/${identifier}${suffix}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue