Skip to content

Commit

Permalink
fix: wrong path (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Jul 23, 2022
1 parent fbed0ad commit 8247d12
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions src/__tests__/__snapshots__/cli.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export declare function $path(
route: \\"/blog/rss.xml\\",
query?: Record<string, string | number>
): string;
export declare function $path(
route: \\"/auth\\",
query?: Record<string, string | number>
): string;
export declare function $path(
route: \\"/auth/login\\",
query?: Record<string, string | number>
): string;
export declare function $path(
route: \\"/s/:query\\",
params: { query: string | number },
Expand Down
6 changes: 5 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function buildHelpers(remixRoot: string): Promise<RoutesInfo> {
if (route.path) {
currentPath = [...currentPath, route];
const fullPath = currentPath.reduce(
(acc, curr) => [acc, curr.path].join('/'),
(acc, curr) => [acc, trimSlash(curr.path!)].join('/'),
'',
);
const paramsNames = parse(currentPath);
Expand Down Expand Up @@ -199,6 +199,10 @@ if (require.main === module) {
})();
}

function trimSlash(path: string) {
return path.replace(/\/+$/, '');
}

function findNearestNodeModulesPath(destDir: string) {
let p = destDir;

Expand Down

0 comments on commit 8247d12

Please sign in to comment.