@@ -489,16 +489,22 @@ fn is_exception(file: &Path, link: &str) -> bool {
489
489
/// If the given HTML file contents is an HTML redirect, this returns the
490
490
/// destination path given in the redirect.
491
491
fn maybe_redirect ( source : & str ) -> Option < String > {
492
- const REDIRECT : & str = "<p>Redirecting to <a href=" ;
492
+ const REDIRECT_RUSTDOC : ( usize , & str ) = ( 7 , "<p>Redirecting to <a href=" ) ;
493
+ const REDIRECT_MDBOOK : ( usize , & str ) = ( 8 - 7 , "<p>Redirecting to... <a href=" ) ;
493
494
494
495
let mut lines = source. lines ( ) ;
495
- let redirect_line = lines. nth ( 7 ) ?;
496
496
497
- redirect_line. find ( REDIRECT ) . map ( |i| {
498
- let rest = & redirect_line[ ( i + REDIRECT . len ( ) + 1 ) ..] ;
499
- let pos_quote = rest. find ( '"' ) . unwrap ( ) ;
500
- rest[ ..pos_quote] . to_owned ( )
501
- } )
497
+ let mut find_redirect = |( line_rel, redirect_pattern) : ( usize , & str ) | {
498
+ let redirect_line = lines. nth ( line_rel) ?;
499
+
500
+ redirect_line. find ( redirect_pattern) . map ( |i| {
501
+ let rest = & redirect_line[ ( i + redirect_pattern. len ( ) + 1 ) ..] ;
502
+ let pos_quote = rest. find ( '"' ) . unwrap ( ) ;
503
+ rest[ ..pos_quote] . to_owned ( )
504
+ } )
505
+ } ;
506
+
507
+ find_redirect ( REDIRECT_RUSTDOC ) . or_else ( || find_redirect ( REDIRECT_MDBOOK ) )
502
508
}
503
509
504
510
fn with_attrs_in_source < F : FnMut ( & str , usize , & str ) > ( source : & str , attr : & str , mut f : F ) {
0 commit comments