Skip to content

Commit ee9d1d0

Browse files
bartlomiejuclaude
andauthored
fix: apply layout to index route with programmatic routing (#3725)
Closes #3553 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9e7adc0 commit ee9d1d0

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

packages/fresh/src/app.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,58 +257,58 @@ export class App<State> {
257257
route: MaybeLazy<Route<State>>,
258258
config?: RouteConfig,
259259
): this {
260-
this.#commands.push(newRouteCmd(path, route, config, false));
260+
this.#commands.push(newRouteCmd(path, route, config, true));
261261
return this;
262262
}
263263

264264
/**
265265
* Add middlewares for GET requests at the specified path.
266266
*/
267267
get(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
268-
this.#commands.push(newHandlerCmd("GET", path, middlewares, false));
268+
this.#commands.push(newHandlerCmd("GET", path, middlewares, true));
269269
return this;
270270
}
271271
/**
272272
* Add middlewares for POST requests at the specified path.
273273
*/
274274
post(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
275-
this.#commands.push(newHandlerCmd("POST", path, middlewares, false));
275+
this.#commands.push(newHandlerCmd("POST", path, middlewares, true));
276276
return this;
277277
}
278278
/**
279279
* Add middlewares for PATCH requests at the specified path.
280280
*/
281281
patch(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
282-
this.#commands.push(newHandlerCmd("PATCH", path, middlewares, false));
282+
this.#commands.push(newHandlerCmd("PATCH", path, middlewares, true));
283283
return this;
284284
}
285285
/**
286286
* Add middlewares for PUT requests at the specified path.
287287
*/
288288
put(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
289-
this.#commands.push(newHandlerCmd("PUT", path, middlewares, false));
289+
this.#commands.push(newHandlerCmd("PUT", path, middlewares, true));
290290
return this;
291291
}
292292
/**
293293
* Add middlewares for DELETE requests at the specified path.
294294
*/
295295
delete(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
296-
this.#commands.push(newHandlerCmd("DELETE", path, middlewares, false));
296+
this.#commands.push(newHandlerCmd("DELETE", path, middlewares, true));
297297
return this;
298298
}
299299
/**
300300
* Add middlewares for HEAD requests at the specified path.
301301
*/
302302
head(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
303-
this.#commands.push(newHandlerCmd("HEAD", path, middlewares, false));
303+
this.#commands.push(newHandlerCmd("HEAD", path, middlewares, true));
304304
return this;
305305
}
306306

307307
/**
308308
* Add middlewares for all HTTP verbs at the specified path.
309309
*/
310310
all(path: string, ...middlewares: MaybeLazy<Middleware<State>>[]): this {
311-
this.#commands.push(newHandlerCmd("ALL", path, middlewares, false));
311+
this.#commands.push(newHandlerCmd("ALL", path, middlewares, true));
312312
return this;
313313
}
314314

packages/fresh/src/app_test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ Deno.test("App - .appWrapper()", async () => {
824824
expect(await res.text()).toContain("<body>app/index<");
825825
});
826826

827-
Deno.test.ignore("App - .layout()", async () => {
827+
Deno.test("App - .layout()", async () => {
828828
const app = new App()
829829
.layout("/", ({ Component }) => (
830830
<>
@@ -840,7 +840,6 @@ Deno.test.ignore("App - .layout()", async () => {
840840

841841
const server = new FakeServer(app.handler());
842842

843-
// The `/foo` layout is not applied for GET `/foo`, is that correct?
844843
const res = await server.get("/foo");
845844
expect(await res.text()).toContain("<body>layout/foo/index<");
846845
});

0 commit comments

Comments
 (0)