File tree 2 files changed +19
-4
lines changed
2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -713,6 +713,11 @@ mod test {
713
713
assert_redirect ( & format ! ( "/{}" , krate) , & target, web) ?;
714
714
assert_redirect ( & format ! ( "/{}/" , krate) , & target, web) ?;
715
715
}
716
+ let target = format ! ( "https://doc.rust-lang.org/stable/proc_macro/" ) ;
717
+
718
+ // with or without slash
719
+ assert_redirect ( "/proc-macro" , & target, web) ?;
720
+ assert_redirect ( "/proc-macro/" , & target, web) ?;
716
721
Ok ( ( ) )
717
722
} )
718
723
}
Original file line number Diff line number Diff line change @@ -142,6 +142,11 @@ pub(super) fn build_routes() -> Routes {
142
142
super :: rustdoc:: RustLangRedirector :: new ( redirect) ,
143
143
) ;
144
144
}
145
+ // redirect proc-macro to proc_macro
146
+ routes. internal_page (
147
+ "/proc-macro" ,
148
+ super :: rustdoc:: RustLangRedirector :: new ( "proc_macro" ) ,
149
+ ) ;
145
150
146
151
routes
147
152
}
@@ -320,10 +325,15 @@ impl Handler for BlockBlacklistedPrefixes {
320
325
/// Automatically generate a Route ID from a pattern. Every non-alphanumeric character is replaced
321
326
/// with `_`.
322
327
fn calculate_id ( pattern : & str ) -> String {
323
- pattern
324
- . chars ( )
325
- . map ( |c| if c. is_alphanumeric ( ) { c } else { '_' } )
326
- . collect ( )
328
+ let calculate_char = |c : char | {
329
+ if c. is_alphanumeric ( ) || c == '-' {
330
+ c
331
+ } else {
332
+ '_'
333
+ }
334
+ } ;
335
+
336
+ pattern. chars ( ) . map ( calculate_char) . collect ( )
327
337
}
328
338
329
339
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments