Skip to content

Commit 692a7b1

Browse files
committed
Better handle chain redirection detection
1 parent 085f5a1 commit 692a7b1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/api/redirection_loop.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,6 @@ impl RedirectionLoop {
9696
}
9797

9898
if i > 1 {
99-
// If the url cannot be parsed, let's treat it as a relative Url.
100-
// Otherwise, we check if the corresponding domain is registered in the project.
101-
if let Ok(url) = Url::parse(&current_url) {
102-
if !project_domains.is_empty() && !project_domains.contains(&url.host_str().unwrap().to_string()) {
103-
// The current url target a domain that is not registered in the project.
104-
// So we consider there is no redirection loop here.
105-
break;
106-
}
107-
}
108-
10999
error = Some(RedirectionError::AtLeastOneHop);
110100
}
111101

@@ -131,6 +121,16 @@ impl RedirectionLoop {
131121
method: current_method.clone(),
132122
});
133123

124+
// If the url cannot be parsed, let's treat it as a relative Url.
125+
// Otherwise, we check if the corresponding domain is registered in the project.
126+
if let Ok(url) = Url::parse(&current_url) {
127+
if !project_domains.is_empty() && !project_domains.contains(&url.host_str().unwrap().to_string()) {
128+
// The current url target a domain that is not registered in the project.
129+
// So we consider there is no redirection loop here.
130+
break;
131+
}
132+
}
133+
134134
if i >= max_hops {
135135
error = Some(RedirectionError::TooManyHops);
136136
break;

0 commit comments

Comments
 (0)