TanStackT
TanStack6mo ago
5 replies
foolish-indigo

Remove tailing /

Is it possible to make routes with wildcards dont show the last
/
if the splat is undefined?

Lets say i have the route /search/$.tsx if i do
navigate({
    to: '/search/$',
    params: {
        _splat: 'test/test'
    }
})


it navigates to /search/test/test as expected, and if i do
navigate({
    to: '/search/$',
    params: {
        _splat: ''
    }
})


it navigates to /search/ wich also makes sense, but i dont really like how the url ends up looking, with the tailing
/
. Is there any better way to do this? i think optional path params dont work since the splat can have multiple
/
Was this page helpful?