@@ -171,12 +171,23 @@ impl Handler for CratesfyiHandler {
171171 }
172172 }
173173
174- // try serving shared rustdoc resources first, then db/static file handler and last router
175- // return 404 if none of them return Ok. It is important that the router comes last,
176- // because it gives the most specific errors, e.g. CrateNotFound or VersionNotFound
177- self . shared_resource_handler
174+ // This is kind of a mess.
175+ //
176+ // Almost all files should be served through the `router_handler`; eventually
177+ // `shared_resource_handler` should go through the router too, and `database_file_handler`
178+ // could be removed altogether.
179+ //
180+ // Unfortunately, combining `shared_resource_handler` with the `router_handler` breaks
181+ // things, because right now `shared_resource_handler` allows requesting files from *any*
182+ // subdirectory and the router requires us to give a specific path. Changing them to a
183+ // specific path means that buggy docs from 2018 will have missing CSS (#1181) so until
184+ // that's fixed, we need to keep the current (buggy) behavior.
185+ //
186+ // It's important that `router_handler` comes first so that local rustdoc files take
187+ // precedence over global ones (see #1324).
188+ self . router_handler
178189 . handle ( req)
179- . or_else ( |e| if_404 ( e, || self . router_handler . handle ( req) ) )
190+ . or_else ( |e| if_404 ( e, || self . shared_resource_handler . handle ( req) ) )
180191 . or_else ( |e| if_404 ( e, || self . database_file_handler . handle ( req) ) )
181192 . or_else ( |e| {
182193 let err = if let Some ( err) = e. error . downcast_ref :: < error:: Nope > ( ) {
0 commit comments