From 6f5f9d68d723cf38abb36aeaf1d4e9ed32d11296 Mon Sep 17 00:00:00 2001 From: Todd Dugan Date: Tue, 11 Mar 2025 13:08:02 -0700 Subject: [PATCH] fix-issue-45 - ensure makeRoute always returns absolute path for NextJS. --- .gitignore | 1 + assets/nextjs/makeRoute.tsx | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a284d13..4deee17 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ dist node_modules .idea +.tasks diff --git a/assets/nextjs/makeRoute.tsx b/assets/nextjs/makeRoute.tsx index 0b39734..5b282cf 100644 --- a/assets/nextjs/makeRoute.tsx +++ b/assets/nextjs/makeRoute.tsx @@ -167,10 +167,14 @@ function createPathBuilder>( .map((e) => e(params)) .filter(Boolean) .join("/"); + + // FIXED: Always ensure an absolute path by adding a leading slash if (catchAllSegment) { - return p + catchAllSegment(params); + return p.length + ? `/${p}${catchAllSegment(params)}` + : `/${catchAllSegment(params).substring(1)}`; } else { - return p.length ? p : "/"; + return p.length ? `/${p}` : "/"; } }; }