@@ -15,7 +15,6 @@ import {
1515import {
1616 isFeedSSBURI ,
1717 isMessageSSBURI ,
18- isSSBURI ,
1918 toFeedSigil ,
2019 toMessageSigil ,
2120 getFeedSSBURIRegex ,
@@ -43,7 +42,7 @@ const ELLIPSIS = '\u2026';
4342 * Match URIs *except* SSB URIs and File URIs
4443 */
4544function getMiscURIRegex ( ) {
46- return / \b ( (? = [ a - z ] + : ) (? ! ( s s b : | f i l e : ) ) ) [ a - z ] + : ( \/ \/ ) ? [ ^ ) \n ] + / g;
45+ return / \b ( (? = [ a - z - ] + : ) (? ! ( s s b : | f i l e : ) ) ) [ a - z - ] + : ( \/ \/ ) ? [ ^ ) \n ] + / g;
4746}
4847
4948const textProps : TextProps = {
@@ -421,6 +420,14 @@ function makeRenderers(
421420 style : styles . link ,
422421 onPress : ( event ) => {
423422 event . stopPropagation ( ) ;
423+
424+ if ( ! isHTTPLink ) {
425+ event . preventDefault ( ) ;
426+ GlobalEventBus . dispatch ( {
427+ type : 'triggerUnrecognizedLink' ,
428+ url : properHref ,
429+ } ) ;
430+ }
424431 } ,
425432 [ 'href' as any ] : properHref ,
426433 } ,
@@ -434,7 +441,15 @@ function makeRenderers(
434441 style : styles . link ,
435442 onPress : ( event ) => {
436443 event . stopPropagation ( ) ;
437- Linking . openURL ( props . href ) ;
444+ if ( isHTTPLink ) {
445+ Linking . openURL ( props . href ) ;
446+ } else {
447+ event . preventDefault ( ) ;
448+ GlobalEventBus . dispatch ( {
449+ type : 'triggerUnrecognizedLink' ,
450+ url : props . href ,
451+ } ) ;
452+ }
438453 } ,
439454 } ,
440455 child ?? props . children ,
@@ -517,8 +532,7 @@ export interface Props {
517532}
518533
519534function transformLinkUri ( uri : string ) {
520- if ( isSSBURI ( uri ) ) return uri ; // don't interfere with SSB URIs
521- return ReactMarkdown . uriTransformer ( uri ) ; // interfere with all others
535+ return uri ; // don't interfere with any URIs
522536}
523537
524538export default class Markdown extends PureComponent < Props > {
@@ -527,7 +541,6 @@ export default class Markdown extends PureComponent<Props> {
527541 const linkifySsbSigilMsgs = linkifyRegex ( Ref . msgIdRegex ) ;
528542 const linkifySsbUriFeeds = linkifyRegex ( getFeedSSBURIRegex ( ) ) ;
529543 const linkifySsbUriMsgs = linkifyRegex ( getMessageSSBURIRegex ( ) ) ;
530- const linkifyMiscUris = linkifyRegex ( getMiscURIRegex ( ) ) ;
531544 const linkifyHashtags = linkifyRegex (
532545 new RegExp ( '#(' + getUnicodeWordRegex ( ) . source + '|\\d|-)+' , 'gu' ) ,
533546 ) ;
@@ -540,7 +553,6 @@ export default class Markdown extends PureComponent<Props> {
540553 . use ( linkifySsbUriMsgs )
541554 . use ( linkifySsbSigilFeeds )
542555 . use ( linkifySsbSigilMsgs )
543- . use ( linkifyMiscUris )
544556 . use ( linkifyHashtags )
545557 . use ( imagesToSsbServeBlobs , { port : portMappings . get ( 'ssb-serve-blobs' ) } )
546558 . processSync ( this . props . text ) . contents ,
0 commit comments