@@ -1289,17 +1289,17 @@ mod tests {
1289
1289
. to_string ( ) ;
1290
1290
schema. push_str ( ",\n " ) ;
1291
1291
1292
- let mut new_schema = schema . clone ( ) ;
1292
+ // Transform the asciidoc form link to markdown style.
1293
1293
let url_matches = schema. match_indices ( "https://" ) ;
1294
- let mut cnt = 0 ;
1295
- for ( idx, _) in url_matches {
1294
+ let mut url_offsets = url_matches. map ( |( idx, _) | idx) . collect :: < Vec < usize > > ( ) ;
1295
+ url_offsets. reverse ( ) ;
1296
+ for idx in url_offsets {
1296
1297
let link = & schema[ idx..] ;
1297
1298
// matching on whitespace to ignore normal links
1298
1299
if let Some ( link_end) = link. find ( |c| c == ' ' || c == '[' ) {
1299
1300
if link. chars ( ) . nth ( link_end) == Some ( '[' ) {
1300
- new_schema. insert ( idx + cnt, '(' ) ;
1301
- new_schema. insert ( idx + link_end + cnt + 1 , ')' ) ;
1302
- cnt = cnt + 2 ;
1301
+ schema. insert ( idx, '(' ) ;
1302
+ schema. insert ( idx + link_end + 1 , ')' ) ;
1303
1303
}
1304
1304
}
1305
1305
}
@@ -1314,9 +1314,9 @@ mod tests {
1314
1314
let end = package_json. find ( end_marker) . unwrap ( ) ;
1315
1315
1316
1316
let p = remove_ws ( & package_json[ start..end] ) ;
1317
- let s = remove_ws ( & new_schema ) ;
1317
+ let s = remove_ws ( & schema ) ;
1318
1318
if !p. contains ( & s) {
1319
- package_json. replace_range ( start..end, & new_schema ) ;
1319
+ package_json. replace_range ( start..end, & schema ) ;
1320
1320
ensure_file_contents ( & package_json_path, & package_json)
1321
1321
}
1322
1322
}
0 commit comments