tatethurston / nextjs-routes

Type safe routing for Next.js
MIT License
553 stars 20 forks source link

Allow trailling slashes #168

Closed piotrgrundas closed 2 months ago

piotrgrundas commented 11 months ago

Currently, the lib always strips the trailing slashes when using route function.

I would expect that it respects the next config trailingSlash or at least respect some flag for determining if the trailing slash should be stripped or not.

This leads to unnecessary redirects if someone uses trailingSlash: true.

tatethurston commented 11 months ago

Thanks @piotrgrundas agreed that the ideal behavior is to use the next config value. I’d accept a PR for this.

For any future contributors:

The trailing slash would need to be generated here. The link above is the wrong location -- that is for type generation, though an argument could be made that trailingSlash should be represented in the generated types as well.