Skip to content

Commit ebdab73

Browse files
Remove get_query_and_fragment function and only get query
1 parent 2bbe794 commit ebdab73

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/web/rustdoc.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,6 @@ pub(crate) async fn rustdoc_html_server_handler(
362362
// Pages generated by Rustdoc are not ready to be served with a CSP yet.
363363
csp.suppress(true);
364364

365-
fn get_query_and_fragment(uri: &Uri) -> Option<&str> {
366-
// We cannot extract the fragment (`#`) with current `Uri` API so forced to do ugly
367-
// things like that...
368-
uri.path_and_query()
369-
.and_then(|path_and_query| path_and_query.as_str().split_once('?').map(|s| s.1))
370-
}
371-
372365
// Convenience function to allow for easy redirection
373366
#[instrument]
374367
fn redirect(
@@ -379,9 +372,12 @@ pub(crate) async fn rustdoc_html_server_handler(
379372
uri: &Uri,
380373
) -> AxumResult<AxumResponse> {
381374
trace!("redirect");
382-
let query = get_query_and_fragment(uri);
383375
Ok(axum_cached_redirect(
384-
EscapedURI::new(&format!("/{}/{}/{}", name, vers, path.join("/")), query).as_str(),
376+
EscapedURI::new(
377+
&format!("/{}/{}/{}", name, vers, path.join("/")),
378+
uri.query(),
379+
)
380+
.as_str(),
385381
cache_policy,
386382
)?
387383
.into_response())
@@ -399,11 +395,10 @@ pub(crate) async fn rustdoc_html_server_handler(
399395
let matched_release = match_version(&mut conn, &params.name, &params.version)
400396
.await?
401397
.into_exactly_named_or_else(|corrected_name, req_version| {
402-
let query = get_query_and_fragment(&uri);
403398
AxumNope::Redirect(
404399
EscapedURI::new(
405400
&format!("/{}/{}/{}", corrected_name, req_version, req_path.join("/")),
406-
query,
401+
uri.query(),
407402
),
408403
CachePolicy::NoCaching,
409404
)

0 commit comments

Comments
 (0)