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:
co-authored by
Claude Opus 4.6
parent
9e7adc084b
commit
ee9d1d04e7
@@ -257,7 +257,7 @@ export class App<State> {
|
|||||||
route: MaybeLazy<Route<State>>,
|
route: MaybeLazy<Route<State>>,
|
||||||
config?: RouteConfig,
|
config?: RouteConfig,
|
||||||
): this {
|
): this {
|
||||||
this.#commands.push(newRouteCmd(path, route, config, false));
|
this.#commands.push(newRouteCmd(path, route, config, true));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,42 +265,42 @@ export class App<State> {
|
|||||||
* Add middlewares for GET requests at the specified path.
|
* Add middlewares for GET requests at the specified path.
|
||||||
*/
|
*/
|
||||||
get(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Add middlewares for POST requests at the specified path.
|
* Add middlewares for POST requests at the specified path.
|
||||||
*/
|
*/
|
||||||
post(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Add middlewares for PATCH requests at the specified path.
|
* Add middlewares for PATCH requests at the specified path.
|
||||||
*/
|
*/
|
||||||
patch(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Add middlewares for PUT requests at the specified path.
|
* Add middlewares for PUT requests at the specified path.
|
||||||
*/
|
*/
|
||||||
put(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Add middlewares for DELETE requests at the specified path.
|
* Add middlewares for DELETE requests at the specified path.
|
||||||
*/
|
*/
|
||||||
delete(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Add middlewares for HEAD requests at the specified path.
|
* Add middlewares for HEAD requests at the specified path.
|
||||||
*/
|
*/
|
||||||
head(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ export class App<State> {
|
|||||||
* Add middlewares for all HTTP verbs at the specified path.
|
* Add middlewares for all HTTP verbs at the specified path.
|
||||||
*/
|
*/
|
||||||
all(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -824,7 +824,7 @@ Deno.test("App - .appWrapper()", async () => {
|
|||||||
expect(await res.text()).toContain("<body>app/index<");
|
expect(await res.text()).toContain("<body>app/index<");
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test.ignore("App - .layout()", async () => {
|
Deno.test("App - .layout()", async () => {
|
||||||
const app = new App()
|
const app = new App()
|
||||||
.layout("/", ({ Component }) => (
|
.layout("/", ({ Component }) => (
|
||||||
<>
|
<>
|
||||||
@@ -840,7 +840,6 @@ Deno.test.ignore("App - .layout()", async () => {
|
|||||||
|
|
||||||
const server = new FakeServer(app.handler());
|
const server = new FakeServer(app.handler());
|
||||||
|
|
||||||
// The `/foo` layout is not applied for GET `/foo`, is that correct?
|
|
||||||
const res = await server.get("/foo");
|
const res = await server.get("/foo");
|
||||||
expect(await res.text()).toContain("<body>layout/foo/index<");
|
expect(await res.text()).toContain("<body>layout/foo/index<");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user