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

Commit ec4ac05

Browse files
authored
Merge pull request #5903 from jaiwanth-v/handle-encoded-urls
Handle encoded matrix URLs
2 parents 3890bec + f0f875d commit ec4ac05

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/linkify-matrix.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ matrixLinkify.options = {
255255
target: function(href, type) {
256256
if (type === 'url') {
257257
const transformed = tryTransformPermalinkToLocalHref(href);
258-
if (transformed !== href || href.match(matrixLinkify.ELEMENT_URL_PATTERN)) {
258+
if (transformed !== href || decodeURIComponent(href).match(matrixLinkify.ELEMENT_URL_PATTERN)) {
259259
return null;
260260
} else {
261261
return '_blank';

src/utils/permalinks/Permalinks.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ export function tryTransformPermalinkToLocalHref(permalink: string): string {
346346
return permalink;
347347
}
348348

349-
const m = permalink.match(matrixLinkify.ELEMENT_URL_PATTERN);
349+
const m = decodeURIComponent(permalink).match(matrixLinkify.ELEMENT_URL_PATTERN);
350350
if (m) {
351351
return m[1];
352352
}
@@ -411,8 +411,8 @@ function getPermalinkConstructor(): PermalinkConstructor {
411411

412412
export function parsePermalink(fullUrl: string): PermalinkParts {
413413
const elementPrefix = SdkConfig.get()['permalinkPrefix'];
414-
if (fullUrl.startsWith(matrixtoBaseUrl)) {
415-
return new SpecPermalinkConstructor().parsePermalink(fullUrl);
414+
if (decodeURIComponent(fullUrl).startsWith(matrixtoBaseUrl)) {
415+
return new SpecPermalinkConstructor().parsePermalink(decodeURIComponent(fullUrl));
416416
} else if (elementPrefix && fullUrl.startsWith(elementPrefix)) {
417417
return new ElementPermalinkConstructor(elementPrefix).parsePermalink(fullUrl);
418418
}

0 commit comments

Comments
 (0)