@@ -642,10 +642,37 @@ private void Refresh()
642642 rule . Matches ( inlines , message ) ;
643643 }
644644
645- var matches = REG_SHA_FORMAT ( ) . Matches ( message ) ;
646- for ( int i = 0 ; i < matches . Count ; i ++ )
645+ var urlMatches = REG_URL_FORMAT ( ) . Matches ( message ) ;
646+ for ( int i = 0 ; i < urlMatches . Count ; i ++ )
647647 {
648- var match = matches [ i ] ;
648+ var match = urlMatches [ i ] ;
649+ if ( ! match . Success )
650+ continue ;
651+
652+ var start = match . Index ;
653+ var len = match . Length ;
654+ var intersect = false ;
655+ foreach ( var link in inlines )
656+ {
657+ if ( link . Intersect ( start , len ) )
658+ {
659+ intersect = true ;
660+ break ;
661+ }
662+ }
663+
664+ if ( intersect )
665+ continue ;
666+
667+ var url = message . Substring ( start , len ) ;
668+ if ( Uri . IsWellFormedUriString ( url , UriKind . Absolute ) )
669+ inlines . Add ( new Models . InlineElement ( Models . InlineElementType . Link , start , len , url ) ) ;
670+ }
671+
672+ var shaMatches = REG_SHA_FORMAT ( ) . Matches ( message ) ;
673+ for ( int i = 0 ; i < shaMatches . Count ; i ++ )
674+ {
675+ var match = shaMatches [ i ] ;
649676 if ( ! match . Success )
650677 continue ;
651678
@@ -840,6 +867,9 @@ private void CalcRevisionFileSearchSuggestion()
840867 RevisionFileSearchSuggestion = suggestion ;
841868 }
842869
870+ [ GeneratedRegex ( @"\b(https?://|ftp://)[\w\d\._/\-~%@()+:?&=#!]*[\w\d/]" ) ]
871+ private static partial Regex REG_URL_FORMAT ( ) ;
872+
843873 [ GeneratedRegex ( @"\b([0-9a-fA-F]{6,40})\b" ) ]
844874 private static partial Regex REG_SHA_FORMAT ( ) ;
845875
0 commit comments