fenok / react-router-typesafe-routes

Comprehensive and extensible type-safe routes for React Router v6 with first-class support for nested routes and param validation.
MIT License
145 stars 3 forks source link

Fix path generation when the first segment is optional #43

Closed fenok closed 1 year ago

fenok commented 1 year ago

When the first segment is optional and not provided, the slash before the required segment is not omitted, which is unexpected for the library code, which adds its own slash.

So route(":optional?/:required").buildPath({ required: "req" }) is "//req", for example.