gvergnaud / nextjs-dynamic-routes

[Deprecated] Super simple way to create dynamic routes with Next.js
MIT License
140 stars 7 forks source link

Optional param, slash in address #22

Open lishine opened 5 years ago

lishine commented 5 years ago
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?

gvergnaud commented 5 years ago

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