Open linkified room aliases and permalinks in the app rather than the browser (#34507)

This commit is contained in:
hayyaksi
2026-08-11 15:31:35 +00:00
committed by GitHub
parent 7897b0c71f
commit 76aeb783b6
2 changed files with 22 additions and 8 deletions
@@ -213,10 +213,29 @@ describe("TextualBodyViewModel", () => {
).toThrow("TextualBodyViewModel should only render pending moderation for hidden messages");
});
it("ignores linkified root clicks", () => {
it("rewrites linkified permalink clicks to local hashes", () => {
const vm = createVm();
const preventDefault = jest.fn();
jest.spyOn(permalinkUtils, "tryTransformPermalinkToLocalHref").mockReturnValue("#/room/#room:example.org");
vm.onRootClick({
preventDefault,
target: {
dataset: {
[LINKIFIED_DATA_ATTRIBUTE]: "true",
},
href: "https://matrix.to/#/#room:example.org",
nodeName: "A",
},
} as any);
expect(preventDefault).toHaveBeenCalled();
expect(window.location.hash).toBe("#/room/#room:example.org");
});
it("leaves linkified ordinary links alone", () => {
const vm = createVm();
const preventDefault = jest.fn();
const transformSpy = jest.spyOn(permalinkUtils, "tryTransformPermalinkToLocalHref");
vm.onRootClick({
preventDefault,
@@ -229,8 +248,8 @@ describe("TextualBodyViewModel", () => {
},
} as any);
expect(transformSpy).not.toHaveBeenCalled();
expect(preventDefault).not.toHaveBeenCalled();
expect(window.location.hash).toBe("");
});
it("rewrites permalink clicks to local hashes", () => {