Skip to content

Commit e568b37

Browse files
committed
refactor: simplify generateRelativeId and reuse createRouteId utility
1 parent 546747d commit e568b37

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/react-router-dev/config/routes.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,9 @@ export { route, index, layout, prefix };
319319
*/
320320
export function relative(directory: string): typeof helpers {
321321
const generateRelativeId = (file: string): string => {
322-
const joined = Path.join(directory, file);
323-
const relativePath = Path.isAbsolute(joined)
324-
? Path.relative(process.cwd(), joined)
325-
: joined;
326-
return Path.normalize(stripFileExtension(relativePath));
322+
const absolutePath = Path.resolve(directory, file);
323+
const relativePath = Path.relative(process.cwd(), absolutePath);
324+
return createRouteId(relativePath);
327325
};
328326

329327
return {

0 commit comments

Comments
 (0)