Parse matrix-schemed URIs (#7453)

Co-authored-by: J. Ryan Stinnett <jryans@gmail.com>
Co-authored-by: Dariusz Niemczyk <dariuszn@element.io>
Co-authored-by: Timo K <toger5@hotmail.de>

With this pr all href use matrix matrix.to links. As a consequence right-click copy link will always return get you a sharable matrix.to link.
This commit is contained in:
Travis Ralston 2022-01-20 10:18:47 -07:00 committed by GitHub
parent f59ea6d7ad
commit 6712a5b1c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 254 additions and 100 deletions

View file

@ -175,9 +175,10 @@ const transformTags: IExtendedSanitizeOptions["transformTags"] = { // custom to
if (attribs.href) {
attribs.target = '_blank'; // by default
const transformed = tryTransformPermalinkToLocalHref(attribs.href);
if (transformed !== attribs.href || attribs.href.match(ELEMENT_URL_PATTERN)) {
attribs.href = transformed;
const transformed = tryTransformPermalinkToLocalHref(attribs.href); // only used to check if it is a link that can be handled locally
if (transformed !== attribs.href || // it could be converted so handle locally symbols e.g. @user:server.tdl, matrix: and matrix.to
attribs.href.match(ELEMENT_URL_PATTERN) // for https:vector|riot...
) {
delete attribs.target;
}
}