Merge branch 'fix/issue-11833' of https://github.com/micalevisk/nest into micalevisk-fix/issue-11833

This commit is contained in:
Kamil Myśliwiec
2023-06-19 09:52:01 +02:00

View File

@@ -1,3 +1,4 @@
import { stripEndSlash } from '@nestjs/common/utils/shared.utils';
import { flatten } from '@nestjs/common/decorators/core/dependencies.decorator';
import {
HttpServer,
@@ -107,13 +108,16 @@ export class MiddlewareBuilder implements MiddlewareConsumer {
),
}));
return routes.filter(route => {
const isOverlapped = (v: { path: string; regex: RegExp }) => {
return route.path !== v.path && route.path.match(v.regex);
const isOverlapped = (v: { path: string; regex: RegExp }): boolean => {
const normalizedRoutePath = stripEndSlash(route.path);
return (
normalizedRoutePath !== v.path && v.regex.test(normalizedRoutePath)
);
};
const routeMatch = routesWithRegex.find(isOverlapped);
if (routeMatch === undefined) {
return route;
return route;
}
});
}