You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-10 09:22:25 +03:00
Handle encoded matrix urls
Signed-off-by: Jaiwanth <jaiwanth2011@gmail.com>
This commit is contained in:
@@ -255,7 +255,7 @@ matrixLinkify.options = {
|
|||||||
target: function(href, type) {
|
target: function(href, type) {
|
||||||
if (type === 'url') {
|
if (type === 'url') {
|
||||||
const transformed = tryTransformPermalinkToLocalHref(href);
|
const transformed = tryTransformPermalinkToLocalHref(href);
|
||||||
if (transformed !== href || href.match(matrixLinkify.ELEMENT_URL_PATTERN)) {
|
if (transformed !== href || decodeURIComponent(href).match(matrixLinkify.ELEMENT_URL_PATTERN)) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return '_blank';
|
return '_blank';
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ export function tryTransformPermalinkToLocalHref(permalink: string): string {
|
|||||||
return permalink;
|
return permalink;
|
||||||
}
|
}
|
||||||
|
|
||||||
const m = permalink.match(matrixLinkify.ELEMENT_URL_PATTERN);
|
const m = decodeURIComponent(permalink).match(matrixLinkify.ELEMENT_URL_PATTERN);
|
||||||
if (m) {
|
if (m) {
|
||||||
return m[1];
|
return m[1];
|
||||||
}
|
}
|
||||||
@@ -402,8 +402,8 @@ function getPermalinkConstructor(): PermalinkConstructor {
|
|||||||
|
|
||||||
export function parsePermalink(fullUrl: string): PermalinkParts {
|
export function parsePermalink(fullUrl: string): PermalinkParts {
|
||||||
const elementPrefix = SdkConfig.get()['permalinkPrefix'];
|
const elementPrefix = SdkConfig.get()['permalinkPrefix'];
|
||||||
if (fullUrl.startsWith(matrixtoBaseUrl)) {
|
if (decodeURIComponent(fullUrl).startsWith(matrixtoBaseUrl)) {
|
||||||
return new SpecPermalinkConstructor().parsePermalink(fullUrl);
|
return new SpecPermalinkConstructor().parsePermalink(decodeURIComponent(fullUrl));
|
||||||
} else if (elementPrefix && fullUrl.startsWith(elementPrefix)) {
|
} else if (elementPrefix && fullUrl.startsWith(elementPrefix)) {
|
||||||
return new ElementPermalinkConstructor(elementPrefix).parsePermalink(fullUrl);
|
return new ElementPermalinkConstructor(elementPrefix).parsePermalink(fullUrl);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user