From ee2e14831adaae423142654d605c3bb626f8bba1 Mon Sep 17 00:00:00 2001 From: Kvrzh Date: Wed, 23 Jul 2025 20:48:38 +0300 Subject: [PATCH] Fix route paths on windows --- packages/nexa-core/core/routes.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/nexa-core/core/routes.js b/packages/nexa-core/core/routes.js index 2e34808..4eed7b4 100644 --- a/packages/nexa-core/core/routes.js +++ b/packages/nexa-core/core/routes.js @@ -12,6 +12,9 @@ const routesFolder = path.join(NEXA_MAIN_LOCATION, '../routes'); const convertToRoutePath = (filePath) => { let routePath = filePath.replace(routesFolder, '').replace(/\.js$/, ''); + // Normalize path separators to forward slashes + routePath = routePath.replace(/\\/g, '/'); + // Replace dynamic Next.js routes (e.g., [slug].js) with Express parameters (e.g., :slug) routePath = routePath.replace(/\[(.*?)\]/g, ':$1'); @@ -20,6 +23,9 @@ const convertToRoutePath = (filePath) => { return '/'; // Home route } + if (!routePath.startsWith('/')) routePath = '/' + routePath; + routePath = routePath.replace(/\/+/g, '/'); + return routePath; };