nextjs-dynamic-routes
nextjs-dynamic-routes copied to clipboard
Optional param, slash in address
router.add({
name: 'register',
pattern: '/register/:barcode?',
page: '/register',
})
doing
router.replaceRoute('register', {}, { shallow: true })
resulting in an address:
http://localhost:3000/register/
Is it intentional ? Though it is working, I would like the address to not include the slash: http://localhost:3000/register How to achieve this? Need change in the package source?
Hey,
Sorry for answering this late, I didn't have much time recently to take care of this.
I agree removing the trailing slash would be cleaner, and I think it does necessitate some changes in the package code. It shouldn't be too hard though :) If you want to give it a try, feel free to clone the package and open a PR fixing this. You can test your implementation by updating this test and running npm run test.
Cheers