fix: layered middleware not working for index page (#407)
This commit fixes layered middleware not being invoked for the the index page of the layer. For example: routes/api/_middleware.ts was not being invoked for /api, only /api/foobar
This commit is contained in:
@@ -9,16 +9,16 @@ Deno.test("selectMiddlewares", () => {
|
||||
"_middleware",
|
||||
"api/_middleware",
|
||||
"api/[id]/_middleware",
|
||||
"api/[id]/[path]/_middleware",
|
||||
|
||||
// should not select
|
||||
"api/xyz/_middleware",
|
||||
"api/[id]/xyz/_middleware",
|
||||
"api/[id]/[path]/_middleware",
|
||||
"api/[id]/[path]/foo/_middleware",
|
||||
];
|
||||
const mwRoutes = middlewaresPath.map((path) =>
|
||||
middlewarePathToPattern(path)
|
||||
) as MiddlewareRoute[];
|
||||
const mws = selectMiddlewares(url, mwRoutes);
|
||||
assert(mws.length === 3);
|
||||
assert(mws.length === 4);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user