Skip to content

Commit 6c24e02

Browse files
committed
fix potentially broken redirect from rustdoc
1 parent e4dc493 commit 6c24e02

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/web/rustdoc.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,16 @@ pub(crate) async fn rustdoc_html_server_handler(
542542
} else if req_path.first().map_or(false, |p| p.contains('-')) {
543543
// This is a target, not a module; it may not have been built.
544544
// Redirect to the default target and show a search page instead of a hard 404.
545-
redirect(
546-
&format!("/crate/{}", params.name),
547-
&format!("{}/target-redirect", version),
548-
&req_path,
545+
Ok(axum_cached_redirect(
546+
format!(
547+
"/crate/{}/{}/target-redirect/{}",
548+
params.name,
549+
version,
550+
req_path.join("/")
551+
),
549552
CachePolicy::ForeverInCdn,
550-
)
553+
)?
554+
.into_response())
551555
} else {
552556
Err(AxumNope::ResourceNotFound)
553557
};

0 commit comments

Comments
 (0)