mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-03 06:55:44 +00:00
feat(permalinks): point Share links/QR at to.healthchat.ch
Add a config-driven matrix_to_url option so Share dialog links and QR codes resolve against a matrix.to-compatible resolver instead of the hardcoded public matrix.to. MatrixToPermalinkConstructor now reads the base URL lazily from config (default https://matrix.to), keeping the matrix.to URL format. HealthChat configs point it at the in-house fork https://to.healthchat.ch and drop the conflicting permalink_prefix (which routes to the Element-format constructor a matrix.to fork can't parse).
This commit is contained in:
@@ -8,6 +8,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
|
||||
import MatrixToPermalinkConstructor from "../../../../src/utils/permalinks/MatrixToPermalinkConstructor";
|
||||
import { PermalinkParts } from "../../../../src/utils/permalinks/PermalinkConstructor";
|
||||
import SdkConfig from "../../../../src/SdkConfig";
|
||||
|
||||
describe("MatrixToPermalinkConstructor", () => {
|
||||
const peramlinkConstructor = new MatrixToPermalinkConstructor();
|
||||
@@ -49,4 +50,32 @@ describe("MatrixToPermalinkConstructor", () => {
|
||||
).toEqual("https://matrix.to/#/!myroom:example.com/$event4?via=one.example.com&via=two.example.com");
|
||||
});
|
||||
});
|
||||
|
||||
describe("with a custom matrix_to_url config", () => {
|
||||
beforeEach(() => {
|
||||
SdkConfig.add({ matrix_to_url: "https://to.healthchat.ch" });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
SdkConfig.reset();
|
||||
});
|
||||
|
||||
it("generates links against the configured host", () => {
|
||||
const constructor = new MatrixToPermalinkConstructor();
|
||||
expect(constructor.forUser("@user:example.com")).toEqual("https://to.healthchat.ch/#/@user:example.com");
|
||||
expect(constructor.forRoom("!myroom:example.com", [])).toEqual(
|
||||
"https://to.healthchat.ch/#/!myroom:example.com",
|
||||
);
|
||||
});
|
||||
|
||||
it("parses links from the configured host and rejects matrix.to links", () => {
|
||||
const constructor = new MatrixToPermalinkConstructor();
|
||||
expect(constructor.parsePermalink("https://to.healthchat.ch/#/@user:example.com")).toEqual(
|
||||
new PermalinkParts(null, null, "@user:example.com", null),
|
||||
);
|
||||
expect(() => constructor.parsePermalink("https://matrix.to/#/@user:example.com")).toThrow(
|
||||
new Error("Does not appear to be a permalink"),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user