From 91236e55335f41f507d8cd6d1f11703f1e264b41 Mon Sep 17 00:00:00 2001 From: Valerio Ageno <51341197+Valerioageno@users.noreply.github.com> Date: Sat, 4 Jan 2025 12:07:20 +0100 Subject: [PATCH] fix: catch-all server side handler (#287) --- packages/tuono-fs-router-vite-plugin/src/generator.ts | 3 +-- .../tests/generator/catch_all/routeTree.expected.ts | 1 + .../tests/generator/catch_all/routes/posts/[...catch_all].rs | 0 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routes/posts/[...catch_all].rs diff --git a/packages/tuono-fs-router-vite-plugin/src/generator.ts b/packages/tuono-fs-router-vite-plugin/src/generator.ts index 657d90f6..53e5f5b7 100644 --- a/packages/tuono-fs-router-vite-plugin/src/generator.ts +++ b/packages/tuono-fs-router-vite-plugin/src/generator.ts @@ -85,8 +85,7 @@ async function getRouteNodes( } else if (fullPath.match(/\.(rs)$/)) { const filePath = replaceBackslash(path.join(dir, dirent.name)) const filePathNoExt = removeExt(filePath) - let routePath = - cleanPath(`/${filePathNoExt.split('.').join('/')}`) || '' + let routePath = cleanPath(`/${filePathNoExt}`) || '' if (routePath === 'index') { routePath = '/' diff --git a/packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routeTree.expected.ts b/packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routeTree.expected.ts index a50af4c9..7910bdd7 100644 --- a/packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routeTree.expected.ts +++ b/packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routeTree.expected.ts @@ -24,6 +24,7 @@ const IndexRoute = Index.update({ const PostscatchallRoute = Postscatchall.update({ path: '/posts/[...catch_all]', getParentRoute: () => rootRoute, + hasHandler: true, }) // Create and export the route tree diff --git a/packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routes/posts/[...catch_all].rs b/packages/tuono-fs-router-vite-plugin/tests/generator/catch_all/routes/posts/[...catch_all].rs new file mode 100644 index 00000000..e69de29b