fix route registration
This commit is contained in:
parent
032af39785
commit
95608fc0a5
1 changed files with 15 additions and 12 deletions
|
@ -58,7 +58,7 @@ class FastifyManager {
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const [routePath, prefix, recursive] of routePaths) {
|
for (const [routePath, prefix, recursive] of routePaths) {
|
||||||
const modifiedRoutePath = join(environment.paths.www.root, routePath);
|
const modifiedRoutePath: string = join(environment.paths.www.root, routePath);
|
||||||
|
|
||||||
let files: string[];
|
let files: string[];
|
||||||
try {
|
try {
|
||||||
|
@ -83,14 +83,17 @@ class FastifyManager {
|
||||||
|
|
||||||
let routePath = routeInfo.path || "/";
|
let routePath = routeInfo.path || "/";
|
||||||
|
|
||||||
// Handle prefix and leading/trailing slashes
|
|
||||||
if (prefix) {
|
if (prefix) {
|
||||||
routePath = routePath === "/" ? prefix : join(prefix, routePath);
|
routePath = routePath === "/" ? prefix : join(prefix, routePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize the path to avoid duplicate slashes
|
routePath = routePath.replace(/\\/g, '/');
|
||||||
routePath = routePath.replace(/\/+/g, "/");
|
|
||||||
|
|
||||||
|
if (!routePath.startsWith('/')) {
|
||||||
|
routePath = '/' + routePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
routePath = routePath.replace(/\/+/g, "/");
|
||||||
const methods = Array.isArray(routeInfo.method) ? routeInfo.method : [routeInfo.method];
|
const methods = Array.isArray(routeInfo.method) ? routeInfo.method : [routeInfo.method];
|
||||||
|
|
||||||
for (const method of methods) {
|
for (const method of methods) {
|
||||||
|
|
Loading…
Reference in a new issue