@@ -642,10 +642,37 @@ private void Refresh()
642
642
rule . Matches ( inlines , message ) ;
643
643
}
644
644
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 ++ )
647
647
{
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 ] ;
649
676
if ( ! match . Success )
650
677
continue ;
651
678
@@ -840,6 +867,9 @@ private void CalcRevisionFileSearchSuggestion()
840
867
RevisionFileSearchSuggestion = suggestion ;
841
868
}
842
869
870
+ [ GeneratedRegex ( @"\b(https?://|ftp://)[\w\d\._/\-~%@()+:?&=#!]*[\w\d/]" ) ]
871
+ private static partial Regex REG_URL_FORMAT ( ) ;
872
+
843
873
[ GeneratedRegex ( @"\b([0-9a-fA-F]{6,40})\b" ) ]
844
874
private static partial Regex REG_SHA_FORMAT ( ) ;
845
875
0 commit comments