This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -254,11 +254,15 @@ matrixLinkify.options = {
254254
255255 target : function ( href , type ) {
256256 if ( type === 'url' ) {
257- const transformed = tryTransformPermalinkToLocalHref ( href ) ;
258- if ( transformed !== href || decodeURIComponent ( href ) . match ( matrixLinkify . ELEMENT_URL_PATTERN ) ) {
259- return null ;
260- } else {
261- return '_blank' ;
257+ try {
258+ const transformed = tryTransformPermalinkToLocalHref ( href ) ;
259+ if ( transformed !== href || decodeURIComponent ( href ) . match ( matrixLinkify . ELEMENT_URL_PATTERN ) ) {
260+ return null ;
261+ } else {
262+ return '_blank' ;
263+ }
264+ } catch ( e ) {
265+ // malformed URI
262266 }
263267 }
264268 return null ;
Original file line number Diff line number Diff line change @@ -346,9 +346,14 @@ export function tryTransformPermalinkToLocalHref(permalink: string): string {
346346 return permalink ;
347347 }
348348
349- const m = decodeURIComponent ( permalink ) . match ( matrixLinkify . ELEMENT_URL_PATTERN ) ;
350- if ( m ) {
351- return m [ 1 ] ;
349+ try {
350+ const m = decodeURIComponent ( permalink ) . match ( matrixLinkify . ELEMENT_URL_PATTERN ) ;
351+ if ( m ) {
352+ return m [ 1 ] ;
353+ }
354+ } catch ( e ) {
355+ // Not a valid URI
356+ return permalink ;
352357 }
353358
354359 // A bit of a hack to convert permalinks of unknown origin to Element links
You can’t perform that action at this time.
0 commit comments