Skip to content

Commit 4886465

Browse files
committed
fix check for redirect loop in rustdoc redirector
1 parent d9a1774 commit 4886465

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/web/rustdoc.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use axum::{
3434
http::StatusCode,
3535
response::{IntoResponse, Response as AxumResponse},
3636
};
37-
use http::{HeaderValue, Uri, header};
37+
use http::{HeaderValue, Uri, header, uri::Authority};
3838
use serde::Deserialize;
3939
use std::{
4040
collections::HashMap,
@@ -231,7 +231,9 @@ pub(crate) async fn rustdoc_redirector_handler(
231231
};
232232

233233
if let Some(original_uri) = original_uri
234-
&& original_uri.path() == original_uri.path()
234+
&& original_uri.path() == url.path()
235+
&& (url.authority().is_none()
236+
|| url.authority() == Some(&Authority::from_static("docs.rs")))
235237
{
236238
return Err(anyhow!(
237239
"infinite redirect detected, \noriginal_uri = {}, redirect_url = {}",

0 commit comments

Comments
 (0)