Ignore permalink_prefix when serializing pills (#11726)
* Ignore permalink_prefix when serializing Markdown fixes vector-im/element-web/issues/26002 During serialization of messages, pills were wrongfully serialized to a URL starting with `permalink_prefix`. This is against the Spec (which mandates https://matrix.to/#/ links) and the resulting pills were not recognized as pills in other clients. Spec-Appendix concerning matrix.to links: https://spec.matrix.org/v1.8/appendices/#matrixto-navigation Signed-off-by: Lars Wickel <git@herkulessi.de> * Test for pill serialization with permalink_prefix set Signed-off-by: Lars Wickel <git@herkulessi.de> * Test that permalink_prefix is used for permalink creation Signed-off-by: Lars Wickel <git@herkulessi.de> * Fix lint issues introduced Signed-off-by: Lars Wickel <git@herkulessi.de> * Incorporate requested changes Signed-off-by: Lars Wickel <git@herkulessi.de> --------- Signed-off-by: Lars Wickel <git@herkulessi.de> Co-authored-by: herkulessi <git@herkulessi.de> Co-authored-by: David Baker <dbkr@users.noreply.github.com>
This commit is contained in:
parent
e6a3238621
commit
fa60edf00f
4 changed files with 82 additions and 11 deletions
|
@ -25,6 +25,8 @@ import {
|
|||
parsePermalink,
|
||||
RoomPermalinkCreator,
|
||||
} from "../../../src/utils/permalinks/Permalinks";
|
||||
import { IConfigOptions } from "../../../src/IConfigOptions";
|
||||
import SdkConfig from "../../../src/SdkConfig";
|
||||
import { getMockClientWithEventEmitter } from "../../test-utils";
|
||||
|
||||
describe("Permalinks", function () {
|
||||
|
@ -391,6 +393,17 @@ describe("Permalinks", function () {
|
|||
expect(result).toBe("https://matrix.to/#/@someone:example.org");
|
||||
});
|
||||
|
||||
it("should use permalink_prefix for permalinks", function () {
|
||||
const sdkConfigGet = SdkConfig.get;
|
||||
jest.spyOn(SdkConfig, "get").mockImplementation((key: keyof IConfigOptions, altCaseName?: string) => {
|
||||
if (key === "permalink_prefix") {
|
||||
return "https://element.fs.tld";
|
||||
} else return sdkConfigGet(key, altCaseName);
|
||||
});
|
||||
const result = makeUserPermalink("@someone:example.org");
|
||||
expect(result).toBe("https://element.fs.tld/#/user/@someone:example.org");
|
||||
});
|
||||
|
||||
describe("parsePermalink", () => {
|
||||
it("should correctly parse room permalinks with a via argument", () => {
|
||||
const result = parsePermalink("https://matrix.to/#/!room_id:server?via=some.org");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue