You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-05 23:10:41 +03:00
Converge on permalink processing for HtmlUtils and linkify-matrix
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
Copyright 2015, 2016 OpenMarket Ltd
|
||||
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -15,6 +16,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
import {baseUrl} from "./utils/permalinks/SpecPermalinkConstructor";
|
||||
import {tryTransformPermalinkToLocalHref} from "./utils/permalinks/RoomPermalinkCreator";
|
||||
|
||||
function matrixLinkify(linkify) {
|
||||
// Text tokens
|
||||
@@ -225,20 +227,8 @@ matrixLinkify.options = {
|
||||
case 'roomalias':
|
||||
case 'userid':
|
||||
case 'groupid':
|
||||
return matrixLinkify.MATRIXTO_BASE_URL + '/#/' + href;
|
||||
default: {
|
||||
// FIXME: horrible duplication with HtmlUtils' transform tags
|
||||
let m = href.match(matrixLinkify.VECTOR_URL_PATTERN);
|
||||
if (m) {
|
||||
return m[1];
|
||||
}
|
||||
m = href.match(matrixLinkify.MATRIXTO_URL_PATTERN);
|
||||
if (m) {
|
||||
const entity = m[1];
|
||||
if (matrixToEntityMap[entity[0]]) return matrixToEntityMap[entity[0]] + entity;
|
||||
}
|
||||
|
||||
return href;
|
||||
return tryTransformPermalinkToLocalHref(href);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -249,8 +239,8 @@ matrixLinkify.options = {
|
||||
|
||||
target: function(href, type) {
|
||||
if (type === 'url') {
|
||||
if (href.match(matrixLinkify.VECTOR_URL_PATTERN) ||
|
||||
href.match(matrixLinkify.MATRIXTO_URL_PATTERN)) {
|
||||
const transformed = tryTransformPermalinkToLocalHref(href);
|
||||
if (transformed !== href || href.match(matrixLinkify.VECTOR_URL_PATTERN)) {
|
||||
return null;
|
||||
} else {
|
||||
return '_blank';
|
||||
|
||||
Reference in New Issue
Block a user