Skip to content

Commit

Permalink
fix panic in target-redirect when called with corrected name
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed May 19, 2024
1 parent 8aca72f commit c60d3ee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/web/crate_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl CrateDetails {
) -> Result<Self> {
Ok(Self::new(
conn,
&release.name,
&release.corrected_name.unwrap_or(release.name),
&release.release.version,
Some(release.req_version),
release.all_releases,
Expand Down
19 changes: 19 additions & 0 deletions src/web/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1859,6 +1859,25 @@ mod test {
});
}

#[test]
fn test_target_redirect_with_corrected_name() {
wrapper(|env| {
env.fake_release()
.name("foo_ab")
.version("0.0.1")
.archive_storage(true)
.create()?;

let web = env.frontend();
assert_redirect_unchecked(
"/crate/foo-ab/0.0.1/target-redirect/x86_64-unknown-linux-gnu",
"/foo-ab/0.0.1/foo_ab/",
web,
)?;
Ok(())
})
}

#[test]
fn test_target_redirect_not_found() {
wrapper(|env| {
Expand Down

0 comments on commit c60d3ee

Please sign in to comment.