diff --git a/src/garage/tests/s3/website.rs b/src/garage/tests/s3/website.rs index 2292137a..7a16eda1 100644 --- a/src/garage/tests/s3/website.rs +++ b/src/garage/tests/s3/website.rs @@ -566,24 +566,68 @@ async fn test_website_redirect_full_bucket() { .await .unwrap(); - 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 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 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:{}/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] diff --git a/src/web/web_server.rs b/src/web/web_server.rs index fc9c0492..64e4ec01 100644 --- a/src/web/web_server.rs +++ b/src/web/web_server.rs @@ -559,7 +559,7 @@ fn path_to_keys( }; if let Some(condition) = &routing_rule.condition { 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; }; Some(suffix)