fix: apply layout to index route with programmatic routing (#3725)

Closes #3553

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bartek Iwańczuk
2026-03-29 21:14:34 +02:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 9e7adc084b
commit ee9d1d04e7
2 changed files with 9 additions and 10 deletions
+8 -8
View File
@@ -257,7 +257,7 @@ export class App<State> {
route: MaybeLazy<Route<State>>,
config?: RouteConfig,
): this {
this.#commands.push(newRouteCmd(path, route, config, false));
this.#commands.push(newRouteCmd(path, route, config, true));
return this;
}
@@ -265,42 +265,42 @@ export class App<State> {
* Add middlewares for GET requests at the specified path.
*/
get(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
this.#commands.push(newHandlerCmd("GET", path, middlewares, false));
this.#commands.push(newHandlerCmd("GET", path, middlewares, true));
return this;
}
/**
* Add middlewares for POST requests at the specified path.
*/
post(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
this.#commands.push(newHandlerCmd("POST", path, middlewares, false));
this.#commands.push(newHandlerCmd("POST", path, middlewares, true));
return this;
}
/**
* Add middlewares for PATCH requests at the specified path.
*/
patch(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
this.#commands.push(newHandlerCmd("PATCH", path, middlewares, false));
this.#commands.push(newHandlerCmd("PATCH", path, middlewares, true));
return this;
}
/**
* Add middlewares for PUT requests at the specified path.
*/
put(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
this.#commands.push(newHandlerCmd("PUT", path, middlewares, false));
this.#commands.push(newHandlerCmd("PUT", path, middlewares, true));
return this;
}
/**
* Add middlewares for DELETE requests at the specified path.
*/
delete(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
this.#commands.push(newHandlerCmd("DELETE", path, middlewares, false));
this.#commands.push(newHandlerCmd("DELETE", path, middlewares, true));
return this;
}
/**
* Add middlewares for HEAD requests at the specified path.
*/
head(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
this.#commands.push(newHandlerCmd("HEAD", path, middlewares, false));
this.#commands.push(newHandlerCmd("HEAD", path, middlewares, true));
return this;
}
@@ -308,7 +308,7 @@ export class App<State> {
* Add middlewares for all HTTP verbs at the specified path.
*/
all(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
this.#commands.push(newHandlerCmd("ALL", path, middlewares, false));
this.#commands.push(newHandlerCmd("ALL", path, middlewares, true));
return this;
}
+1 -2
View File
@@ -824,7 +824,7 @@ Deno.test("App - .appWrapper()", async () => {
expect(await res.text()).toContain("<body>app/index<");
});
Deno.test.ignore("App - .layout()", async () => {
Deno.test("App - .layout()", async () => {
const app = new App()
.layout("/", ({ Component }) => (
<>
@@ -840,7 +840,6 @@ Deno.test.ignore("App - .layout()", async () => {
const server = new FakeServer(app.handler());
// The `/foo` layout is not applied for GET `/foo`, is that correct?
const res = await server.get("/foo");
expect(await res.text()).toContain("<body>layout/foo/index<");
});