mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 11:47:23 +03:00
Merge pull request #5903 from jaiwanth-v/handle-encoded-urls
Handle encoded matrix URLs
This commit is contained in:
commit
ec4ac05684
2 changed files with 4 additions and 4 deletions
|
@ -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';
|
||||
|
|
|
@ -346,7 +346,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];
|
||||
}
|
||||
|
@ -411,8 +411,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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue