Skip to content

Commit 61c1d83

Browse files
Add missing redirection in rustdoc_redirector_handler
1 parent ebdab73 commit 61c1d83

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/web/rustdoc.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,11 @@ pub(crate) async fn rustdoc_redirector_handler(
253253
.into_response())
254254
} else {
255255
Ok(axum_cached_redirect(
256-
format!("/crate/{crate_name}/{}", matched_release.req_version),
256+
EscapedURI::new(
257+
&format!("/crate/{crate_name}/{}", matched_release.req_version),
258+
uri.query(),
259+
)
260+
.as_str(),
257261
CachePolicy::ForeverInCdn,
258262
)?
259263
.into_response())
@@ -2983,4 +2987,26 @@ mod test {
29832987
Ok(())
29842988
})
29852989
}
2990+
2991+
#[test_case(true)]
2992+
#[test_case(false)]
2993+
fn test_redirect_with_query_args(archive_storage: bool) {
2994+
async_wrapper(|env| async move {
2995+
env.fake_release()
2996+
.await
2997+
.name("fake")
2998+
.version("0.0.1")
2999+
.archive_storage(archive_storage)
3000+
.rustdoc_file("fake/index.html")
3001+
.binary(true) // binary => rustdoc_status = false
3002+
.create()
3003+
.await?;
3004+
3005+
let web = env.web_app().await;
3006+
web.assert_redirect("/fake?a=b", "/crate/fake/latest?a=b")
3007+
.await?;
3008+
3009+
Ok(())
3010+
});
3011+
}
29863012
}

0 commit comments

Comments
 (0)