Skip to content
Source
Sign inSign up
TanStack/router

fix(router): `rewriteBasepath` not working without trailing slash #5244

Mergedthenglong(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/5244/headmerged by schiller-manuel(GitHub profile, opens in a new tab)

Showing 2 changed files with 158 additions and 5 deletions.

x
0 of 2 viewed, 2 left
138 additions and 0 deletionspackages/react-router/tests/router.test.tsxModified
View file
@@ -2670,6 +2670,144 @@
expect(router.state.location.pathname).toBe('/users')
+ it.each([
+ {
+ description: 'basepath with leading slash but without trailing slash',
+ basepath: '/api/v1',
+ },
+ {
+ description: 'basepath without leading slash but with trailing slash',
+ basepath: 'api/v1/',
+ },
+ {
+ description: 'basepath without leading and trailing slashes',
+ basepath: 'api/v1',
+ },
+ ])('should handle $description', async ({ basepath }) => {
+ const rootRoute = createRootRoute({
+ component: () => <Outlet />,
+ })
+​
+ const usersRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/users',
+ component: () => <div data-testid="users">Users</div>,