Skip to content

Commit 10b7233

Browse files
authored
matrix.to urls for aliases don't need a via param (#348)
1 parent 625b62c commit 10b7233

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ export async function replaceRoomIdsWithPills(mjolnir: Mjolnir, text: string, ro
226226
const regexRoomId = new RegExp(escapeRegex(roomId), "g");
227227
content.body = content.body.replace(regexRoomId, alias);
228228
if (content.formatted_body) {
229-
content.formatted_body = content.formatted_body.replace(regexRoomId, `<a href="${Permalinks.forRoom(alias, viaServers)}">${alias}</a>`);
229+
const permalink = Permalinks.forRoom(alias, alias !== roomId ? [] : viaServers);
230+
content.formatted_body = content.formatted_body.replace(regexRoomId, `<a href="${permalink}">${alias}</a>`);
230231
}
231232
}
232233

test/integration/utilsTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ describe("Test: utils", function() {
2020
const out = await replaceRoomIdsWithPills(
2121
this.mjolnir,
2222
`it's fun here in ${this.mjolnir.managementRoomId}`,
23-
new Set([this.mjolnir.managementRoomId])
23+
new Set([this.mjolnir.managementRoomId, "!myfaketestid:example.com"])
2424
);
2525

2626
const ourHomeserver = new UserID(await this.mjolnir.client.getUserId()).domain;
2727
assert.equal(
2828
out.formatted_body,
29-
`it's fun here in <a href="https://matrix.to/#/${managementRoomAlias}?via=${ourHomeserver}">${managementRoomAlias}</a>`
29+
`it's fun here in <a href="https://matrix.to/#/${managementRoomAlias}">${managementRoomAlias}</a>`
3030
);
3131
});
3232
});

0 commit comments

Comments
 (0)