don't append index document to redirect urls

This commit is contained in:
trinity-1686a
2025-11-06 18:03:58 +01:00
parent b275dc5000
commit ca2a190b2f
2 changed files with 62 additions and 18 deletions
+44
View File
@@ -566,6 +566,7 @@ async fn test_website_redirect_full_bucket() {
.await .await
.unwrap(); .unwrap();
{
let req = Request::builder() let req = Request::builder()
.method("GET") .method("GET")
.uri(format!("http://127.0.0.1:{}/my-path", ctx.garage.web_port)) .uri(format!("http://127.0.0.1:{}/my-path", ctx.garage.web_port))
@@ -586,6 +587,49 @@ async fn test_website_redirect_full_bucket() {
); );
} }
{
let req = Request::builder()
.method("GET")
.uri(format!("http://127.0.0.1:{}/my-path/", ctx.garage.web_port))
.header("Host", format!("{}.web.garage", BCKT_NAME))
.body(Body::new(Bytes::new()))
.unwrap();
let client = Client::builder(TokioExecutor::new()).build_http();
let resp = client.request(req).await.unwrap();
assert_eq!(resp.status(), StatusCode::FOUND);
assert_eq!(
resp.headers()
.get(hyper::header::LOCATION)
.unwrap()
.to_str()
.unwrap(),
"https://other.tld/my-path/"
);
}
{
let req = Request::builder()
.method("GET")
.uri(format!("http://127.0.0.1:{}/", ctx.garage.web_port))
.header("Host", format!("{}.web.garage", BCKT_NAME))
.body(Body::new(Bytes::new()))
.unwrap();
let client = Client::builder(TokioExecutor::new()).build_http();
let resp = client.request(req).await.unwrap();
assert_eq!(resp.status(), StatusCode::FOUND);
assert_eq!(
resp.headers()
.get(hyper::header::LOCATION)
.unwrap()
.to_str()
.unwrap(),
"https://other.tld/"
);
}
}
#[tokio::test] #[tokio::test]
async fn test_website_redirect() { async fn test_website_redirect() {
const BCKT_NAME: &str = "my-redirect"; const BCKT_NAME: &str = "my-redirect";
+1 -1
View File
@@ -559,7 +559,7 @@ fn path_to_keys(
}; };
if let Some(condition) = &routing_rule.condition { if let Some(condition) = &routing_rule.condition {
let suffix = if let Some(prefix) = &condition.prefix { let suffix = if let Some(prefix) = &condition.prefix {
let Some(suffix) = key.strip_prefix(prefix) else { let Some(suffix) = base_key.strip_prefix(prefix) else {
continue; continue;
}; };
Some(suffix) Some(suffix)