@@ -93,26 +93,20 @@ fn find_raw_urls(
93
93
trace ! ( "looking for raw urls in {text}" ) ;
94
94
// For now, we only check "full" URLs (meaning, starting with "http://" or "https://").
95
95
for match_ in URL_REGEX . find_iter ( text) {
96
- let url_range = match_. range ( ) ;
96
+ let mut url_range = match_. range ( ) ;
97
+ url_range. start += range. start ;
98
+ url_range. end += range. start ;
97
99
let mut without_brackets = None ;
98
- let mut extra_range = 0 ;
99
100
// If the whole text is contained inside `[]`, then we need to replace the brackets and
100
101
// not just add `<>`.
101
- if whole_text[ ..range . start + url_range. start ] . ends_with ( '[' )
102
- && range . start + url_range. end <= whole_text. len ( )
103
- && whole_text[ range . start + url_range. end ..] . starts_with ( ']' )
102
+ if whole_text[ ..url_range. start ] . ends_with ( '[' )
103
+ && url_range. end <= whole_text. len ( )
104
+ && whole_text[ url_range. end ..] . starts_with ( ']' )
104
105
{
105
- extra_range = 1 ;
106
+ url_range. start -= 1 ;
107
+ url_range. end += 1 ;
106
108
without_brackets = Some ( match_. as_str ( ) ) ;
107
109
}
108
- f (
109
- cx,
110
- "this URL is not a hyperlink" ,
111
- Range {
112
- start : range. start + url_range. start - extra_range,
113
- end : range. start + url_range. end + extra_range,
114
- } ,
115
- without_brackets,
116
- ) ;
110
+ f ( cx, "this URL is not a hyperlink" , url_range, without_brackets) ;
117
111
}
118
112
}
0 commit comments