1 parent
31634543f0
commit
a238ff5e23
2 files changed
+17
-11
No files matched your search
+9
-1
@@ -502,7 +502,15 @@ pub fn create_router(
|
|||||||
// Use the same base path for routing and authentication cookies.
|
// Use the same base path for routing and authentication cookies.
|
||||||
let router = match config.normalized_base_path() {
|
let router = match config.normalized_base_path() {
|
||||||
"/" => inner,
|
"/" => inner,
|
||||||
base_path => Router::new().nest(base_path, inner),
|
base_path => {
|
||||||
|
// Axum nests an inner `/` route at the prefix itself (`/mail`),
|
||||||
|
// not at the trailing-slash variant (`/mail/`). Serve that variant
|
||||||
|
// explicitly so both URLs load the same embedded SPA.
|
||||||
|
let base_path_slash = format!("{}/", base_path.trim_end_matches('/'));
|
||||||
|
Router::new()
|
||||||
|
.route(&base_path_slash, get(crate::ui::serve_ui))
|
||||||
|
.nest(base_path, inner)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let router = router
|
let router = router
|
||||||
|
|||||||
+8
-10
@@ -377,21 +377,19 @@ async fn base_path_serves_the_same_embedded_ui() {
|
|||||||
test_idle_manager(),
|
test_idle_manager(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
for uri in ["/mail", "/mail/"] {
|
||||||
let response = app
|
let response = app
|
||||||
.oneshot(
|
.clone()
|
||||||
Request::builder()
|
.oneshot(Request::builder().uri(uri).body(Body::empty()).unwrap())
|
||||||
.uri("/mail/")
|
|
||||||
.body(Body::empty())
|
|
||||||
.unwrap(),
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(response.status(), StatusCode::OK);
|
assert_eq!(response.status(), StatusCode::OK, "{uri}");
|
||||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||||
let html = String::from_utf8(body.to_vec()).unwrap();
|
let html = String::from_utf8(body.to_vec()).unwrap();
|
||||||
assert!(html.contains("data-base-path=\"/mail\""));
|
assert!(html.contains("data-base-path=\"/mail\""), "{uri}");
|
||||||
assert!(html.contains("/mail/assets/app."));
|
assert!(html.contains("/mail/assets/app."), "{uri}");
|
||||||
assert!(html.contains(".js"));
|
assert!(html.contains(".js"), "{uri}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|||||||
Reference in new issue
Block a user