Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Handle encoded matrix URLs #5903

Merged
merged 2 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/linkify-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ matrixLinkify.options = {
target: function(href, type) {
if (type === 'url') {
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;
} else {
return '_blank';
Expand Down
6 changes: 3 additions & 3 deletions src/utils/permalinks/Permalinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export function tryTransformPermalinkToLocalHref(permalink: string): string {
return permalink;
}

const m = permalink.match(matrixLinkify.ELEMENT_URL_PATTERN);
const m = decodeURIComponent(permalink).match(matrixLinkify.ELEMENT_URL_PATTERN);
if (m) {
return m[1];
}
Expand Down Expand Up @@ -402,8 +402,8 @@ function getPermalinkConstructor(): PermalinkConstructor {

export function parsePermalink(fullUrl: string): PermalinkParts {
const elementPrefix = SdkConfig.get()['permalinkPrefix'];
if (fullUrl.startsWith(matrixtoBaseUrl)) {
return new SpecPermalinkConstructor().parsePermalink(fullUrl);
if (decodeURIComponent(fullUrl).startsWith(matrixtoBaseUrl)) {
return new SpecPermalinkConstructor().parsePermalink(decodeURIComponent(fullUrl));
} else if (elementPrefix && fullUrl.startsWith(elementPrefix)) {
return new ElementPermalinkConstructor(elementPrefix).parsePermalink(fullUrl);
}
Expand Down