T
TanStack3w ago
continuing-cyan

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'
}
})
navigate({
to: '/search/$',
params: {
_splat: 'test/test'
}
})
it navigates to /search/test/test as expected, and if i do
navigate({
to: '/search/$',
params: {
_splat: ''
}
})
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 /
2 Replies
like-gold
like-gold3w ago
might just be a bug. it should adhere to the trailingSlash option IMO can you please create a github issue for this? ideally, create a failing unit test as a PR
continuing-cyan
continuing-cyanOP3w ago
i can definitly create the issue and ill take a look at the unit tests thanks manuel

Did you find this page helpful?