message: Add redirect for rustdoc_html_server_handler
diff: @@ -210,7 +210,7 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
  /// also crate-specific.
  pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
  let router = extension!(req, Router);
  - let mut name = router.find("crate").unwrap_or("").to_string();
  + let name = router.find("crate").unwrap_or("").to_string();
  let url_version = router.find("version");
  let version; // pre-declaring it to enforce drop order relative to `req_path`
  let conn = extension!(req, Pool).get();
  @@ -223,13 +223,10 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
  req_path.remove(0);
  }
  + let corrected_name;
  version = match match_version(&conn, &name, url_version) {
  Some(mv) => {
  - if let Some(new_name) = mv.corrected_name {
  - // `match_version` checked against -/_ typos, so if we have a name here we should
  - // use that instead
  - name = new_name;
  - }
  + corrected_name = mv.corrected_name;
  match mv.version {
  MatchSemver::Exact((v, _)) => v,
  @@ -247,6 +244,13 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
  None => return Err(IronError::new(Nope::ResourceNotFound, status::NotFound)),
  };
  + if let Some(name) = corrected_name {
  + let url = ctry!(Url::parse(
  + &format!("{}/{}/{}/{}", base, name, version, req_path.join("/"))[..]
  + ));
  + return Ok(super::redirect(url));
  + }
  +
  // docs have "rustdoc" prefix in database
  req_path.insert(0, "rustdoc");
  @@ -880,11 +884,6 @@ mod test {
  "/dummy-dash/0.1.0/dummy_dash/index.html",
  web,
  )?;
  - assert_redirect(
  - "/crate/dummy_mixed_separators",
  - "/crate/dummy_mixed-separators",
  - web,
  - )?;
  Ok(())
  })
  