feature request: get the original path from a built route
guesant opened this issue · comments
Gabriel R. Antunes commented
Let's suppose we have
import { Ruty } from 'ruty'
const { route } = Ruty.configure({
prefix: '/:language'
})
const routes = {
userById: route('/user/:id?created&sort').build(),
}
routes.userById({ id: 123 })
// '/user/123'
There is a way to get something like this?
routes.userById.path()
// /:language/user/:id
Or
routes.userById.path({includeParams: true}) // or just send `true` to get the original route
// /:language/user/:id/created&sort
Thank you for doing this package, I'll use it a lot.
Edit: or maybe this syntax
routes.userById.path({params: true}) // to get all the original params
routes.userById.path({params: { created: true, sort: false }}) // to get `/user/:id?created`
Gabriel R. Antunes commented
hmm... it already does
Lines 28 to 32 in cc395b1
Rubens Mariuzzo commented
Does that help you?
Gabriel R. Antunes commented
Yes. Thank you!