mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
Merge branch 'fix/issue-11833' of https://github.com/micalevisk/nest into micalevisk-fix/issue-11833
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user